[OT] Argument list too long
Eldridge, Michael
michael.eldridge at evolveddigital.com
Fri Aug 12 17:00:42 UTC 2005
> > cp -r /media/nethd/Sound/a* /media/Sound/
>
> I tried this and it works.
>
> Can I do something like (pseudo code):
> foreach
> (abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789)
> cp -r /media/nethd/Sound/$_* /media/Sound/
> next
>
> I am not a bash programmer but I heard/read that you can do
> stuff like
> this in the batch
you can, by following this construct:
$ for i in a b c d e; do cp -r /media/nethd/Sound/$i /media/Sound/; done
however, rather than typing all those out on the command
line, you could be a little sneakier:
$ for i in `ls /media/nethd/Sound/ | cut -c 1 | uniq`; do cp -r /media/nethd/Sound/$i /media/Sound; done
the -c argument to cut will output only the characters specified
(in our case, the first character) and uniq will, as the name
suggests, eliminates duplicates.
-mike
More information about the ubuntu-users
mailing list