Skip to content

Instantly share code, notes, and snippets.

@etigui
Last active October 14, 2020 12:09
Show Gist options
  • Save etigui/ec91b2a285e9b24d05e814cc6368f066 to your computer and use it in GitHub Desktop.
Save etigui/ec91b2a285e9b24d05e814cc6368f066 to your computer and use it in GitHub Desktop.
Bash - find all files under a directory, copy them to another directory named after their parent directory
# https://stackoverflow.com/questions/40959708/find-all-log-files-under-a-directory-copy-them-to-another-directory-named-af
find /stack-exchange/ -type f -iname "*.log" -exec sh -c 'cp "$0" "./logs/$(basename "$(dirname "$0")").log"' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment