0

I want to move huge files to other directory so I used:

find ./ -name f | xargs mv -f sm20180416* /ora_arch/ssmfep_backup/

but i am getting

-bash: /usr/bin/xargs: Argument list too long
-bash: /bin/logger: Argument list too long

it works when moving in small batches of files - but when moving in large number of files i am getting that error. I.e. arguments too long

Faiz
  • 51
  • 3
  • 12
  • How is the mix find, xargs and * supposed to work? I cannot really guess it... – Serge Ballesta May 03 '18 at 07:49
  • 1
    Maybe consider using `rsync` for copying files around effortlessly and efficiently, with restartability and differencing engines. – Mark Setchell May 03 '18 at 07:51
  • I am not really sure what your intentions are with this command but I do not believe this approach would work. The file list created by `find` will be appended to the end of the `mv` command and not in the beginning. (_**`man xargs`:** `xargs` reads items from the standard input, delimited by blanks (which can be protected with double or single quotes or a backslash) or newlines, and executes the command (default is `/bin/echo`) one or more times with any initial-arguments **followed by items read from standard input**._) – kvantour May 03 '18 at 09:04
  • 1
    Possible duplicate of [Argument list too long error for rm, cp, mv commands](https://stackoverflow.com/questions/11289551/argument-list-too-long-error-for-rm-cp-mv-commands) – kvantour May 03 '18 at 09:07
  • Related: [Does “argument list too long” restriction apply to shell builtins?](https://stackoverflow.com/q/47443380/6862601). – codeforester Nov 11 '18 at 17:26

1 Answers1

2

Your command is not correct try with below. It will work for you:-

find ./ -name  "sm20180416*" | xargs -I {} mv -f {} /ora_arch/ssmfep_backup/
Abhijit Pritam Dutta
  • 5,521
  • 2
  • 11
  • 17