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

One Response to “using sed to replace a single value in a config file”

  1. vito says:

    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

Leave a Reply