08-27-2008
3,653,
12
Join Date: Mar 2008
Last Activity: 28 March 2011, 6:41 AM EDT
Location: /there/is/only/bin/sh
Posts: 3,653
Thanks Given: 0
Thanked 12 Times in 10 Posts
Given the correct values in $A and $B, that should not be very hard. However, if this needs to happen in a loop, cd:ing back so that the next iteration of the loop works right is a bit of an issue, especially if there may be symbolic links involved. Probably the easiest is to grab pwd into a variable, and cd back to that location at the end of the loop. Another solution is to run each loop iteration in a subshell; the parent's working directory will remain the same throughout. (Hint: use round parentheses to run commands in a subshell.)