Last active
October 3, 2018 07:21
-
-
Save photonxp/a8bed85e4d0b4405b80dda49393408a8 to your computer and use it in GitHub Desktop.
move files to destination directory in command
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 | |
# Usage: | |
# move files to dir_destination | |
# ./mv_files2dir.bash /path/to/file dir_destination | |
# ./mv_files2dir.bash dir_a ./{b,c} dir_destination | |
# test_mv_files2dir.bash: | |
# #!/bin/bash | |
# | |
# # Test the usage of mv_files2dir.bash | |
# | |
# mkdir -p test/{dir_a,dir_destination} | |
# touch {b,c} | |
# | |
# ./mv_files2dir.bash test/dir_a ./{b,c} dir_destination | |
arr_arglist=($@) | |
idx_dir=$((${#arr_arglist[@]} - 1)) | |
dir_path=${arr_arglist[$idx_dir]} | |
for (( i=0;$i<$idx_dir;i++ )) | |
do | |
echo $i | |
fpath="${arr_arglist[$i]}" | |
echo "mv $fpath $dir_path" | |
mv $fpath $dir_path | |
done |
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 | |
# Test the usage of mv_files2dir.bash | |
mkdir -p test/{dir_a,dir_destination} | |
touch {b,c} | |
./mv_files2dir.bash test/dir_a ./{b,c} dir_destination |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment