View Single Post
Old June 25th, 2006   #7
Quirky
A Carafe of Ubuntu
 
Join Date: Sep 2005
Beans: 86
Re: bash: Copying files in an Alphabetic order

This might do it:
Code:
find . -type f -print0 | sort -z -n  | xargs -0 cp --target-directory='/tmp'
Or if not, another hacky way is to replace the space with a character, then return it to a space before doing the copy. Like this:

Code:
for i in $( ls *.mp3 | sort -n | sed 's% %~%g') ; do  echo "${i/~/ }" ; cp "${i/~/ }" /tmp/  ; done
That depends on the fact that your file doesn't have a "~" in it, which is why it is hacky.
Quirky is offline   Reply With Quote