[CLUE-Tech] sed help

Ed Hill ed at eh3.com
Wed Jan 14 12:48:52 MST 2004


On Tue, 2004-01-13 at 19:32, David Willson wrote:
> I'm going crazy here.
> 
> I want to take strings returned by 'find' and replace the folder-name I was
> searching in with another folder-name, but sed is ~not~ behaving as I want
> it to.
> This works at the command-line:
> >echo "/home/david/.kde" | sed -e s/"\/home\/david"/"\/backups\/david"/
> /backups/david/.kde
> 
> Now, how do I make it work in a script?
> 
> Ultimately, I want something like this:
> find /home/david -type d -exec [! -d `sed -e
> s/'/home/david'/'/home/backups/david'/` ] echo "Error: Directory no found!"

How about:

find /home/david -type d | sed -e 's|/home/|/backup/|g' > tmp
perl -e 'while(<>){if(! -d $_){print "Error: cannot find: $_";}};' <tmp

hth,
Ed

-- 
Edward H. Hill III, PhD
office:  MIT Dept. of EAPS;  Room 54-1424;  77 Massachusetts Ave.
            Cambridge, MA 02139-4307
email:   eh3 at mit.edu,  ed at eh3.com
URL:     http://web.mit.edu/eh3/
phone:   617-253-0098
fax:     617-253-4464
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://cluedenver.org/pipermail/clue-tech/attachments/20040114/1e81aff7/attachment.bin


More information about the clue-tech mailing list