szeto@aludra.usc.edu (Johnny Szeto) (09/23/90)
There is a problem with an interactive shell command I try to use: [shakyamuni:54 :~] foreach i (*2) ? set g=`sed 's/\(.*\)2/\1/'<<fg ? $r[$b] ? fg` ? mv $i $g ? @ b++ ? end The above paragraph is typed on a current shell since I have to change some filenames in the current shell. On line two by the end of the sentence I try to use a here statement so that sed will execute the variable $r[$b] as a standard input typed at the terminal if I use < instead of << thru sed will take the stuff inside the variable, by the way the variable contains filename so sed will take everything inside the file as input rather the filename itself. But the problem is the command substitution quotes `` has to be on the same line since when I execute it it says unmatched `. I guess the problem is when I go to line 3 the shell gives me another subshell prompt so it apparently has already execute line 2 before I complete the `` command. I am quite a novice in programming C-shell. Can someone give me some guidance?
brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (09/24/90)
In article <12126@chaph.usc.edu> szeto@aludra.usc.edu (Johnny Szeto) writes: > ? set g=`sed 's/\(.*\)2/\1/'<<fg > ? $r[$b] > ? fg` The easiest solution (unfortunately) is `echo "$r[$b]" | sed`. ---Dan