Last active
October 6, 2018 23:55
-
-
Save enobufs/cc219a84ba5db1fd9041d7fe746ee285 to your computer and use it in GitHub Desktop.
Copy files with modifying file names in Bash
This file contains hidden or 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 | |
srcdir=./sample | |
dstdir=. | |
array=(`find $srcdir -type f`) | |
#echo Length: ${#array[@]} | |
for i in "${array[@]}" | |
do | |
from="$i" | |
to=$dstdir/`sed -e "s/\.cfg.*/\.cfg/g" <<< $(basename $i)` # modify this line as you need | |
cp $from $to | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment