[ale] Problems w/ mv and sed

Geoffrey esoteric at 3times25.net
Tue Dec 24 14:53:15 EST 2002




David S. Jackson wrote:
> On Tue, Dec 24, 2002 at 01:29:39AM -0500 Stephen Touset <stephen at touset.dyndns.org> wrote:
> 
>>I'll try that in a sec, but I'm wondering why my methods didn't work.
>>The sed command I issued should have (and did) escape out the spaces.
> 
> 
> If the filenames are properly quoted, the spaces don't need escaping.
> And if you escape the quotes, then bash may not see them and it's just
> as if they weren't there.
> 
> Also, the delimiter for "for" loops is a space.  If there are any spaces
> in your files that bash ever sees, "for" will treat them as delimited
> arguments in the forloop,

I don't believe this is correct, as this example demonstrates:

 > ls -l
-rw-r--r--    1 esoteric esoteric        0 Dec 24 14:48 the bar.mp3
-rw-r--r--    1 esoteric esoteric        0 Dec 23 23:28 the foo.mp3

 > for fn in the*;do
echo file: $fn;done
file: the bar.mp3
file: the foo.mp3

Note, there are two files both containing a space.  The for loop 
properly echo's each file on a separate line.


> mv will therefore see them as separate
> arguments rather than a single argument whose string contains a space.

Now this, I believe is the issue, as doing something like:

mv the bar.mp3.OK the bar.mp3

Will complain because it sees 4 arguments and would expect the last one 
to be a directory.

Quoting the args to the above mv statement will resolve this issue.  As 
noted, I don't do bash, but I did test this under bash and it works 
properly, including in the aforementioned for loop.

-- 
Until later: Geoffrey		esoteric at 3times25.net

The latest, most widespread virus?  Microsoft end user agreement.
Think about it...

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list