Skip to content

Instantly share code, notes, and snippets.

@miend
Forked from joshkraemer/useful-terminal.sh
Last active October 10, 2015 17:07
Show Gist options
  • Save miend/3722867 to your computer and use it in GitHub Desktop.
Save miend/3722867 to your computer and use it in GitHub Desktop.
Useful Terminal Commands
# Start an application in the background (leaving terminal free for other use once it starts)
application-name [whatever options] &
# No really, just put & on the end of it. Trust me.
# Recursively find all files named config and replace a string using sed. The -i flag requires a blank suffix '' to work on Mac.
find . -name config -type f -print | xargs sed -i '' 's/[email protected]:CollegePlus/[email protected]:collegeplus/g'
# Recursively find all files with a certain file extension and replace a string using perl.
find . -name "*.fileext" -print | xargs perl -i -p -e 's/STRINGTOFIND/STRINGTOREPLACE/g'
# Display filesystem of mounted volumes
df -T | awk '{print $1,$2,$NF}' | grep "^/dev"
# Recursively force files lowercase with rename
find . -depth -print -execdir rename -f 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \;
# Recursively change spaces to underscores with rename
find . -depth -print -execdir rename -f 'y/ /_/' {} \;
# Trim log files to keep 100 last lines at bottom of file.
find / -name '*'.log | while read x; do sed -i -e :a -e '$q;N;100,$D;ba' $x; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment