MV files with xargs or -exec

Hi

I need to move multiple (say 10 files) from one location to another location. My selection would be like this...

ls -ltr *.arc | head ---> Need to move top 10 files with single command without iterating in loop. I know we can move files like this with find command but not sure if I can move top 10 files in any directory to another one.

Any help would be appreciated.

  • Malay
find . -name '*.arc' | head ...

but it won't necessarily find the top ten biggest without an extra pipe to sort.
Are you thinking about performance? You've got a decent solution already.

Write a script "vm" which works like mv but accepts the destination as the first argument. Then ls -ltr *.arc | xargs -n 10 vm destination

If you have zsh:

mv -- *.arc(Om[1,10]) dest

Modern versions of UNIX allow mv to operate across filesystems - ie., you can move a file from anywhere to anywhere else you have permissions.

Check your mv man page to see what it says about moving file across filesystem boundaries.