How to comment out a line in all files? How to comment out a line in all files? unix unix

How to comment out a line in all files?


You can use sed:

sed -i.bak 's~^[[:blank:]]*include \$DIR/make/makefile\.am~#&~' file


you can run the command suggested by anubhava in a find, if you want to run this on hundreds of files.

find <dir> -type f -name makefile.am -exec sed -i.bak 's~^[[:blank:]]*include \$DIR/make/makefile\.am~#&~' {} \;

where is the base directory under which you want to recursively search makefile.am and comment out the include statement.

Hope it helps you.

You can further tweak the command according to your need.