Skip to content

Instantly share code, notes, and snippets.

@wesleylhandy
Last active June 9, 2020 16:17
Show Gist options
  • Save wesleylhandy/8d7927159c8cbce997521221e60f0ce5 to your computer and use it in GitHub Desktop.
Save wesleylhandy/8d7927159c8cbce997521221e60f0ce5 to your computer and use it in GitHub Desktop.
Bash Command to Copy Files and Rename Using Regex
#!/bin/bash
#
# Utility that reads (-r) files that match a filestring pattern and writes (-w) new files
# using replace string (-s) to ammend the filename using the pax archive utility
# Will not overwrite existing files (-k) and will update access times (-t)
#
# EXAMPLE: pax -rwtks '/IAmPatrickDVD/WrittenInStoneDVD/' *IAmPatrickDVD* .
#
pax -rwtks '/<Find>/<Replace>/' <pattern> <location>
@wesleylhandy
Copy link
Author

Can't use this as a script without using the specific values needed for the script to function. This is an example for further use.

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