![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| making an iso file... | asafronit | SCO | 5 | 03-08-2008 02:18 PM |
| making the changes permanent in a file | vijaya2006 | Shell Programming and Scripting | 4 | 05-22-2007 12:05 PM |
| Making an output file of cscope | eynkesef | UNIX for Dummies Questions & Answers | 1 | 09-07-2006 06:17 AM |
| making change in file without opening it | naamas03 | Shell Programming and Scripting | 0 | 04-04-2006 01:11 AM |
| Making Changes without opening file | irehman | Shell Programming and Scripting | 9 | 03-16-2006 06:13 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
sed : Making changes in the same file
sed 's/abc/xyz/g' abc.txt > abc.txt
This change all the abc s in abc.txt to xyz s but does not write back to the abc.txt. Suggest me the cleaner way without using temp file please. Cheers, Amol. |
| Forum Sponsor | ||
|
|
|
|||
|
Hi,
IMHO there´s no way to work without any tmp files, cause if you redirect the STDOUT to abc.txt the (empty) file is created before sed can read it. So sed is reading an empty file! but what is the problem working with a tmp file? I tried out this an it works fine. sed 's/abc/xyz/g' abc.txt>xyz.txt;mv xyz.txt abc.txt Hope this meets your affords. greetz, Frank |
|
|||
|
I'm afraid isacs is right there..... sed cannot be directed back to it's file....it's just the way it was written.
There are some Unix commands that can.....'sort' for example can have a -o flag set to be the input filename. But sed cannot - there is no cleaner way using sed.
__________________
Pete |
|
|||
|
Ahh, I wonder what would be the reason, this is not provided in sed implementation, maybe they did not want to keep enitre file in memory, this is good when reading bigg files....anyways, I will use the temp files.
temp files is problem coz I am doing this with lots of other files at the same time throught different threads..and although I can create unique temp files, the problem is I would need large free space to creat them as maybe 100s of temp files will be created simultaniously. Hmmm I need to think on this....well....thanks people !! |
|||
| Google The UNIX and Linux Forums |