linux - Need to move a limited # of files on MacOs -
i have requirement move files local macbook remote server using sftp.
i need take 6000 files , move them remote server processing. due limitations on processing system, can process maximum of 100 files @ time. processing system bomb if there more 100 files in folder monitors.
i'd set script run via crontab every x # of minutes , move 100 files folder on mac contains 6,500 files 'staging' folder. 2nd script pick , upload contents of 'staging' folder sftp folder.
i've got crontab working fine, however, can't figure out how limit # of files move 100.
here's i've done far. maybe i'm doing wrong, suggestions appreciated!
#!/bin/bash cd /users/me/downloads/test # files unprocessed 6k files located.
the 'ls' command returns '-bash: /bin/ls: argument list long' error
ls unprocessed/*.pdf | head -n 99 > flist while read f mv "$f" . done < flist
this script upload sftp server.
./exp.sh
this move separate folder completes
for f in *pay*.pdf mv "$f" processed/ done
any appreciated!
your ls
command failing because shell expands file pattern many matching files names in aggregate exceed limit of single command line. not despair, because can replace use of ls
find
:
find unprocessed -name '*.pdf' | head -n 99 > flist
Comments
Post a Comment