more shell goodness with sed
Aug. 6th, 2007 03:25 pmSo, I had a list of items upon which I wanted to run a command.
The command required 2 arguments:
a) the list item and
b) the list item modified by a character substitution
I finally figured out how to mod the variable, and feed it in to my command, thusly:
Hooray sed!
p.s. Yes, I only needed the first instance of char1 on the line replaced. That's why I didn't use the trailing g in the sed replacement.
The command required 2 arguments:
a) the list item and
b) the list item modified by a character substitution
I finally figured out how to mod the variable, and feed it in to my command, thusly:
for item in `cat list.txt`; do command `echo $item | sed 's/char1/char2/'` $item; doneHooray sed!
p.s. Yes, I only needed the first instance of char1 on the line replaced. That's why I didn't use the trailing g in the sed replacement.