Skip to content

Instantly share code, notes, and snippets.

@F1LT3R
Last active July 8, 2023 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save F1LT3R/b5c8d2f040cdbd5a246b12b9912b48f7 to your computer and use it in GitHub Desktop.
Save F1LT3R/b5c8d2f040cdbd5a246b12b9912b48f7 to your computer and use it in GitHub Desktop.
Batch rename files in Linux with "for" and "sed"
# For a list of files like this...
# eng-web_002_GEN_01_read.txt
# eng-web_096_REV_22_read.txt
# Batch rename removing "eng-web_" and "_read"...
for i in *; do mv ${i} $(echo ${i} | sed 's/eng-web_//;s/_read//'); done
# Result is file list like this...
# 002_GEN_01.txt
# 096_REV_22.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment