- Substitute a certain text string in a file with another text string. This command line will also make a backup copy, with the .bak extension, of all the original files. To not have the backup copy made remove the '-i.bak' option. By putting an asterisk for the file_name you can do a mass substition of all files within the directory.
perl -i.bak -wpe 's/a_word/another_word/;' file_name
- Replace all directories found with a copy of another directory.
find . -type d -name directory_name -exec cp -v copied_directory {} \;
- Sort and display directories based on their size.
du -s * | sort -n
- When grep -r doesn't work. (Solaris)
grep foo `find . -type f -name "*.c"`
find . -type f -exec sh -c 'echo {} ; grep foo {} ' \;