Don't forget the -i

2017-04-19 Tags: gnu

I spent way too much time troubleshooting an issue I was having with sed today. This is a common theme sometimes where I spend upwards of an hour debugging something that is ridiculously obvious.

I was trying to replace a string in a file. This is super simple to do with sed.

sed 's/string/replacement_string/` $file_name

The problem is that this command just spits out the result. If you want to actually save your change you must use the -i flag.

sed -i '/s/string/replacement_string/` $file_name

For more information on how to not suck at Linux like Lev please refer to man $command ;)