Trouble using sed
I need to replace 127.0.0.1 on line 49 with an *
I tried: Code:
sed '49s/127.0.0.1/*/' |
Try this
Code:
sed -e '49s/127.0.0.1/*/g' filename.txt |
Quote:
GNU bash, version 4.2.10(1)-release (i686-pc-linux-gnu) GNU sed version 4.2.1 |
Quote:
Code:
"rpc-whitelist": "127.0.0.1", |
Quote:
|
Use the -i switch if you want to apply changes to the same file
Code:
sed -i '49s/127.0.0.1/*/g' filename.txt |
As I said in the OP, I needed to replace a lin so I tried the -i switch and it worked great! Thanks for the quick response!
|
It's cleaner to use the [c]hange command instead of the [s]ubstitution command here.
Code:
sed -i '49c*' file.txt http://www.grymoire.com/Unix/Sed.html http://sed.sourceforge.net/grabbag/ http://sed.sourceforge.net/sedfaq.html http://sed.sourceforge.net/sed1line.txt Another option that I like to use is ed. As a true text editor it's more flexible in many circumstances. But it can also be a bit more hassle to set up. Code:
ed -s file.txt <<<$'49c\n*\n.\nw' http://wiki.bash-hackers.org/howto/edit-ed http://snap.nlc.dcccd.edu/learn/nlc/ed.html (also read the info page) |
All times are GMT -5. The time now is 04:39 AM. |