Instantly share code, notes, and snippets.

Embed
What would you like to do?
Find-Replace string in file's name
#add prefix
rename s/'^'/'MyPrefix'/ *
#add suffix
rename s/'$'/'MySuffix'/ *
#numbered
n=1; for f in ./*.jpg; do mv "$f" $n.jpg; n=$((n+1)); done
find . -type f -printf "%C@ %p\n" | sort -rn | head -n 10
find . -name '*.php' -exec grep -Hn 'SEARCHSTRING' '{}' \
grep --include=\*.{php,php6} -rnw './' -ie "SEARCH"
rename s/"SEARCH"/"REPLACE"/g *
//Replace Text
replace "old_string" "new_string" -- *.php
//Replace with regex
sed -i -- "s/<text .*svg>/<svg>/g" **.svg
//Find text in files
grep --include=\*.{php,php5} -rnw './' -e "NEEDLE"
//Chmod files and dirs
find /path/to/base/dir -type d -print0 | xargs -0 chmod 755
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment