Last active
December 23, 2015 19:50
-
-
Save kitusmark/67ce44102982a909bc6b to your computer and use it in GitHub Desktop.
finds the specified type of file in a directory and copies them in the destination 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
#!/bin/bash | |
# Script that finds a type of file in the current directory (recursive) | |
# and copies them into a destination directory | |
# Remember you need to put the absolute path of directories i.e ~/Desktop/... | |
# 1st parameter is the type of file to search | |
# 2nd parameter is the origin directory | |
# 3rd parameter is the destination directory | |
numberOfParameters=3 | |
if [ "$#" -ne $numberOfParameters ]; then | |
echo "Illegal number of parameters!" | |
exit 1 | |
fi | |
echo "The type of file you search: "$1 | |
echo "The origin directory: "$2 | |
echo "The destination directory: "$3 | |
cd $2 | |
find . -type f -iname "$1" -exec cp -r -v -n {} $3 \; | |
cd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment