On 19Aug2011 14:59, Rob DeSanno <rdesanno@xxxxxxxxx> wrote: | On Fri, Aug 19, 2011 at 2:28 PM, Josh Miller <joshua@xxxxxxxxxxxxxxxxx>wrote: | > On 08/19/2011 11:06 AM, Rob DeSanno wrote: | >> sed -e "s/^'/\<tr\>\<td\>/" $stores_down | sed -e "s/'>/\<\/td\>\<td\>/" | | >> *sed | >> -e "s/-[0-9]/\<\/td\>\<td\>/"* | sed -e "s/$/\<\/td\>\<\/tr\>/">> $log | [...] | > Try this, I've split the sed command into a sed script (file.sed) [...] | | Works like a champ and I was sooo close. Thanks a lot for your help!! Further to Josh's fix for you, I have some suggestions for your future sed uses: - Josh's approach of putting the whole thing in a file is generally a win for anything non-trivial, so try to do it. - If you're working on the command line directly with "sed -e", it is far far better to use single quotes instead of double quotes if you can. In double quotes the $ and backslash characters are subject to shell interpretation, making their use in sed commands more tricky and error prone. I see you've got some single quotes in your opening sed commands, hence perhaps your choice of double quotes, but even then I'd be personally inclined to use single quotes and to leave them just to get the benefit of single quotes in general, eg: sed -e 's/^'\''/<tr><td>/' You see the embedded single quote has become more ugly but the need for other backslashes is greatly reduced. Having once written a sed command line needing exactly 13 conseutive backslashes, I now seek to reduce the need for such nesting. - If you're running multiple sed commands it is more efficient (performant) if they are all in one sed command - this saves copying your data between multiple seds. Of course, this doesn't matter much for small files or infrequent commands, but large files and commands run many times in loops will show the difference. Here again Josh's "put it all in a file" approach makes it easier. - If you're debugging, as you are, multiple sed commands piped together lets you examine the changes more easily, especially via the use of the tee command: sed -e ... | tee stage1.txt | sed -e ... | tee stage2.txt | ... You can then examine the stage1.txt etc files for each transformation in turn. The diff command can also be useful for this examination: diff -u stage1.txt stage2.txt to see what changes the second sed wrought. Cheers, -- Cameron Simpson <cs@xxxxxxxxxx> DoD#743 http://www.cskk.ezoshosting.com/cs/ Copyright and Patents: To prevent the Progress of Science and useful Arts, by securing for unlimited Times to Authors and Inventors and Trolls the exclusive Right to all Writings and Discoveries. - http://science.slashdot.org/story/11/04/26/211258/Copyright-Law-Is-Killing-Science -- redhat-list mailing list unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe https://www.redhat.com/mailman/listinfo/redhat-list