Last active
October 14, 2020 12:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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