using sed to replace a single value in a config file
Which happens to be the only thing I can do with sed /bin/sed -i'' -e's/foo/bar/' /etc/filename
This entry was posted
on Monday, October 19th, 2009 at 2:27 pm and is filed under Note to Self.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
One Response to “using sed to replace a single value in a config file”
The -i flag doesn’t _need_ an argument and you only need -e if you’re going to use multiple expressions. Stop making it more complicated than it needs to be.
Speaking of sed, I like to do stuff like this:
# comment out every line containing "somepattern"
for line in `grep -n somepattern /etc/somefile |cut -d: -f1`; do
sed -i "${line}s/^/\#/g" /etc/somefile
done
The -i flag doesn’t _need_ an argument and you only need -e if you’re going to use multiple expressions. Stop making it more complicated than it needs to be.
Speaking of sed, I like to do stuff like this:
# comment out every line containing "somepattern"
for line in `grep -n somepattern /etc/somefile |cut -d: -f1`; do
sed -i "${line}s/^/\#/g" /etc/somefile
done