While $$$$$$


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting While $$$$$$
# 1  
Old 08-25-2008
While $$$$$$

db2 connect...

LINE=........

while [ "$LINE" != 0 ]
do
read LINE
A=`echo $LINE|awk -F/ '{print $1}'`
B=`echo $LINE|awk -F/ '{print $2}'`
done

echo $A
echo $B
db2 terminate
script ends here

I want to substitute values like

10-hjhj 20=hj 307fgr/45fdg 85fgf56 2fg-lk
10-h 20=hj 307fgr/45gfdg 85fgfdf3453456 2fg-lk
10-hdfgdfjhj 20=hj 307fgdfggr/45fdg 85fgf56 2fg-lk

I want to get the value in $A as 10-hjhj 20=hj 307fgr
and $B as 45fdg 85fgf56 2fg-lk

go to a particular directory cd A/D/$A/$B

then proceed with the next input
$A as 10-h 20=hj 307fgr
$B as 45gfdg 85fgfdf3453456 2fg-lk

go to a particular directory cd A/D/$A/$B
.
.
.
Please help
# 2  
Old 08-27-2008
You almost have it...

Code:
cd "/A/D/$A/$B"

# 3  
Old 08-27-2008
Hi rollthecoin ,

If i'm not wrong the same we discussed earlier. Wat was the issue now?
# 4  
Old 08-27-2008
# 5  
Old 08-27-2008
I believe he needs to change directory based on $A and $B.
# 6  
Old 08-27-2008
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.)
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question