Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Can anyone help me with 'sed' please?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can anyone help me with 'sed' please?



Am Donnerstag, 09.10.03 um 10:16 Uhr schrieb Rob Stott:

I'm using the command...

sed 's/'<PATH>/Users/admin/Desktop/PH7323 NR80 E27 FROSTED 29361<12NCs>62717132 62716652 62705862 62705842 62716632 62705832 62705812'/'NewText'/' '/Volumes/Philips Server/ph_db.txt' > '/Volumes/Philips Server/ph_db.txt'


I'm getting the error report;

Ambiguous input redirect.

Yes, of course ... :-)

You can't read and write a file at the same time. Try:

sed [...] >"/Volumes/Philips Server/tmp$$" && mv "/Volumes/Philips Server/tmp$$" "/Volumes/Philips Server/ph_db.txt"


The "&&" is better than a ";" because the "mv" will be executed on success of the preceding "sed", only.

"$$" is the variable containing the process' PID and is commonly used to generate unique file names.


Depending on how you generate ph_db.txt, you could avoid writing the first file at all by using pipes, e.g.:

ls "/Users/admin/Desktop/PH7323*" | sed [...] >"/Volumes/Philips Server/ph_db.txt"


Have fun,
Markus

- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/
_______________________________________________
darwinos-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwinos-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Can anyone help me with 'sed' please? (From: Rob Stott <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.