Better Programming

Advice for programmers.

Follow publication

Member-only story

10 Frequently Used Bash Scripts and Commands

Kirshi Yin
Better Programming
Published in
3 min readOct 18, 2021
Sudo command
Photo by Gabriel Heinzer on Unsplash

1. Search for Files Recursively To Find an Expression

$ find . -type f -exec grep -l "nltk" {} \;

2. Print the Elapsed Time of Code Execution

3. Search and Replace Strings in Files

$ find . -type f -exec grep -l "localhost:8000" {} \; | xargs sed -i 's/localhost:8000/localhost:8080/g'

4. Delete Specific Files

$ find . -type f -name "*.log" -exec rm {} \;
$ find . -type f -mtime +25 -exec rm {} \;

5. Execute Command on Each File if a Condition Is Met

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Kirshi Yin
Kirshi Yin

Written by Kirshi Yin

Self-taught Java Developer. Explores topics about Spring Boot, NLP, Linux, low-coding, and more. Interested in foreign languages, investment, personal growth.

Responses (4)

Write a response