Terminal Commands CheatSheet

Replace strings in multiple files inside a directory:

$ find . -type f -name '*.txt' -exec sed -i '' s/search_for/replace_with/ {} +

Count number of files in a directory:

$ ls -1 | wc - l

Count number of matches from grep:

$ grep 'text_to_find' -r * | wc -l

Kill process by PID:

$ ps -ef | grep Chrome

Then kill -9 PID

Kill process by process name:

$ killall -9 Chrome

Search a file by it's name, not by content:

$ find | grep 'filename.txt'

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top