ls -al | grep -v '^d' | xargs mv -t mysubdir
I use the above command extensively on Red Hat systems.
It moves all files in the current directory to mysubdir
$ mv --version
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2
what is the above command's equivalent in HP-UX (HP-UX 11i Version 3 Feb 2007)
If xargs
on your HP-UX 11i has the -I
flag you can do this, although I'm not entirely sure how you have managed to use ls -l
output with the mv
:
ls -al | grep -v '^d' | xargs -I {} mv {} mysubdir
Failing that you could do this, which I think would be my preferred solution:
ls -a | while read ITEM; do test ! -d "$ITEM" && mv "$ITEM" mysubdir; done
Either can be encompassed with a shell function or script, so the length of the one-liner isn't necessarily relevant.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments