Created
February 8, 2012 01:41
-
-
Save joshkraemer/1764166 to your computer and use it in GitHub Desktop.
Useful Terminal Commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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