Skip to content

Instantly share code, notes, and snippets.

@alesegdia
Last active August 29, 2015 14:07
Show Gist options
  • Save alesegdia/7c3d5c3db09e3d52cc25 to your computer and use it in GitHub Desktop.
Save alesegdia/7c3d5c3db09e3d52cc25 to your computer and use it in GitHub Desktop.
Useful bash commands
# sort folders/files by disk usage
du -hc . | grep [.]/[^/]*$ | sort -h
# replace in all files
grep -rl matchstring somedir/ | xargs sed -i 's/string1/string2/g'
# script to rename in all files:
#!/usr/bin/env bash
if [ $# -ne 3 ]; then
exit
fi
find $1 -type f -print0 | xargs -0 sed -i "s/$2/$3/g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment