Last active
October 31, 2017 17:09
-
-
Save verginer/3b50f26e75a1031f72ae7c96d2054045 to your computer and use it in GitHub Desktop.
Move n files from dir1 to dir2
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
#!/usr/bin/env bash | |
# move `n` files from source dir to destination | |
# | |
# Example | |
# | |
#$./move_n_files.sh 30 './*.csv' ./dest | |
n_files=$1 # first argument | |
source_dir=$2 # second argument can be a glob i.e. ls *.csv | |
dest_dir=$3 # third argument | |
ls "${source_dir}" | head -n "${n_files}" | xargs -i mv "{}" "${dest_dir}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment