Results 1 to 4 of 4
Sed is like really old, but for some reason, the sed version on one of the boxes I work with, doesn't support inplace editing. this is annoying because you then ...
- 03-19-2008 #1Just Joined!
- Join Date
- Mar 2008
- Posts
- 26
inplace editing (-i) in Sed
Sed is like really old, but for some reason, the sed version on one of the boxes I work with, doesn't support inplace editing. this is annoying because you then generate a new file every time you run it through sed.
I guess you can't specify more than one "find and replace" per sed command, can you? Or there's no trick to it?
I'm not sure I should go and upgrade the version of sed on there in case it breaks something... any ideas?
*edit* I just found replace, but as I want to replace a load of ^Ms with nothing, it won't work :/
- 03-19-2008 #2What OS / version?
Originally Posted by Azrael2
Yes you can; see the -e option.
Originally Posted by Azrael2
One option:
Originally Posted by Azrael2
awk '{ sub("\r$", ""); print; }' your_file_here > new_file_here
Another option:
dos2unix your_file_here
Another option:
Search the forums. This has been discussed before.
- 03-28-2008 #3Just Joined!
- Join Date
- Mar 2008
- Posts
- 26
The best way I found is perl -pi -e and then the same syntax you would use for Sed. Works a treat, and is much tidier. thanks anyway
- 03-28-2008 #4Linux Enthusiast
- Join Date
- Apr 2004
- Location
- UK
- Posts
- 658
There is a program called sponge, which lets you do things like:
without clobbering /file.Code:sed 'pattern' /file | sponge /file
Chris...To be good, you must first be bad. "Newbie" is a rank, not a slight.


Reply With Quote