Skip to content

Instantly share code, notes, and snippets.

@locona
Created September 19, 2018 05:29
Show Gist options
  • Save locona/132a2ca885e13ac027a1f042622910fd to your computer and use it in GitHub Desktop.
Save locona/132a2ca885e13ac027a1f042622910fd to your computer and use it in GitHub Desktop.
hcommand to find recursively files {can be modified for folders too, change -type f}, and renamed them by specfying regex pattern
find . -type f -maxdepth [depth] -name "[filepattern]" | while read FNAME; do mv "$FNAME" "${FNAME//search/replace}"; done
example:
find . -type f -maxdepth 1 -name "domain*.php" | while read FNAME; do mv "$FNAME" "${FNAME//domain/lead}"; done
@locona
Copy link
Author

locona commented Sep 19, 2018

find . -type f -maxdepth 10 -name "*txt" | while read FNAME (gke_cdp-dev-206602_asia-northeast1-a_cdp-dev-k8s/cdp)
do
mv ${FNAME} $(dirname ${FNAME})/node -e 'console.log(Date.now())'.json

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment