I think that the "for x in *" still gets you on the limit (not sure).
This is how you deal with spaces in filenames or '-' find -print0 | xargs -0 rm Another funny unix thing is awk... it solves all your problems but in one line, but then creates new ones until you get them right for separators and special cases. --jm On 02/21/2012 12:31 AM, H. S. Teoh wrote: > On Tue, Feb 21, 2012 at 04:24:44AM +0100, Adam D. Ruppe wrote: >> On Tuesday, 21 February 2012 at 03:13:10 UTC, H. S. Teoh wrote: >>> for x in *; mv $x dest/$x; done >>> >>> Easy. :) >> >> And wrong! >> >> What if the filename has a space in it? You can say "$x", with quotes, >> to handle that. > > Argh, you're right. That's one reason I *hate* the implicit > interpolation that shells have the tendency to do. Perl got it right: $x > means the value of x as a *single* value, no secret additional > interpolation, no multiple layers of re-interpretation, and that > nonsense. > > >> But, worse yet... a leading dash? Another downside with the shell >> expansion is the program can't tell if that is an expanded filename or >> a user option. > > Heh. Never thought of this before. I can see some fun times to be had > with it, though! > > But you could probably handle it by: > > mv -- "$x" "$dest/$x" > > >> In this case, the mv simply wouldn't work, but you can get some >> bizarre behavior out of that if you wanted to play with it. >> >> try this some day as a joke: >> >> $ mkdir evil-unix # toy directory >> $ cd evil-unix >> $ touch -- -l # our lol file >> $ touch cool # just to put a file in there >> $ ls >> -l cool >> $ ls * # the lol file is interpreted as an option! >> -rw-r--r-- 1 me users 0 2012-02-20 22:18 cool >> $ >> >> >> imagine the poor newb trying to understand that! > > +1, LOL. > > > T >