Argument list too long - Unix

后端 未结 4 1986
时光说笑
时光说笑 2020-12-07 01:35

This scripts will sort the files by date then move the first 2500 files to another directory.
When I run below scripts, system prompt out Argument list too long msg. Any

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 02:20

    A quick way to fix this would be to change to $FROM_DIRECTORY, so that you can refer the files using (shorter) relative paths.

    cd $FROM_DIRECTORY && ls -tr MSCERC*.Z|head -2500 |xargs -i sh -c "mv {} $DESTINATION_DIRECTORY"

    This is also not entirely fool-proof, if you have too many files that match.

提交回复
热议问题