Skip to content

Instantly share code, notes, and snippets.

@Nodws Nodws/Add prefix or suffix
Last active Feb 11, 2019

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
// remove thumbs
find ./ \( -name '*x[0-9][0-9][0-9][0-9].*' -o -name '*x[0-9][0-9][0-9].*' -o -name '*x[0-9][0-9].*' \) -delete
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.