Hi all,
I am using a tcsh script to execute commands and call other programs. At one point I need to replace string1 with string2. I have posted here before and kind people referred me to sed which partially worked. My problem is that the strings replacement is executed within a 'foreach' command.
Here is that part in the script:
#!/usr/bin/tcsh
foreach number (1 2 3 4 5 6 7 8 9 10)
cd ${number}
sed 's/string1/${number}/' file1>file2
cd ../
end
which is supposed to:
1. enter the directory named '1'
2. replace string1 with the number '1' in file1
3. save the new file as file2 and exit the directory
4. recursively repeat until the 10th directory
the problem is that instead of replacing string1 with the number, it types in the string '${number}' without recognizing that i am calling the value (e.g 1,2...).
Does anyone know how to fix this - replace string1 with the actual number?
I saw this past posting (
http://www.linuxquestions.org/questi...d+foreach+tcsh)
but it seems slightly different and i am not sure how to apply on my it problem.
I am relatively new to to the unix world so please take that into account if you are writing back.
any suggestion is highly appreciated - thanks a lot,
Ben