[X-Unix] SED help

Andrew Kappy akappy at canfieldtack.com
Thu Nov 3 08:02:18 PST 2005


I'm a rank beginner with command line editing.

The shell is tcsh.

I have a series of about 100 directories each with a "mailto" file  
containing a list of email addresses. I wish to add the same address  
to the end of each of the "mailto" files.

I've used "foreach" and "sed" to do replacements, but adding a new  
line has defeated me so far.

For replacements, I've had success with:


> server 10# foreach file ( `find . -name mailto` )
> foreach? cat $file |sed 's/something/else/g' > $file.tmp
> foreach? mv $file.tmp $file
> foreach? end
>

Thinking that a "\n" would insert as a new line, I tried to replace  
the last line of the mailto file with:
foreach? cat $file |sed  
's/'user1 at company.com'/'user1 at company.com'\n'user2 at company.com'/g' >  
$file.tmp

This ran the two addresses together with an "n" in the middle.

Any suggestions would be greatly appreciated.



More information about the X-Unix mailing list