Re: Stupid spaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Works for me, however I did forget to quote $x in original example.

[rich@deadrat ~/test]$ ls -l
total 0
-rw-rw-r--    1 rich     rich            0 Feb 13 09:19 blah blah.p
-rw-rw-r--    1 rich     rich            0 Feb 13 09:19 this is a test

[rich@deadrat ~/test]$ for x in *; do mv "$x" ${x// /_}; done

[rich@deadrat ~/test]$ ls -l
total 0
-rw-rw-r--    1 rich     rich            0 Feb 13 09:19 blah_blah.p
-rw-rw-r--    1 rich     rich            0 Feb 13 09:19 this_is_a_test

[rich@deadrat ~/test]$ bash --version
GNU bash, version 2.05.8(1)-release (i386-redhat-linux-gnu)
Copyright 2000 Free Software Foundation, Inc.
 

On Fri, 13 Feb 2004, Scott Taylor wrote:

> Date: Fri, 13 Feb 2004 08:33:33 -0800
> From: Scott Taylor <scott@xxxxxxxxxxxxxxx>
> To: linux-admin@xxxxxxxxxxxxxxx
> Subject: Re: Stupid spaces
> 
> At 06:15 PM 02/12/2004, rich+ml@xxxxxxxxxxx wrote:
> >How about:
> >
> >  for x in *; do mv $x ${x// /_}; done
> 
> That's kinda what I was thinking, only problem with that is, the file named 
> "blah blah.p" will cause an error as bash/sh/ksh will think it is two files.
> mv: cannot stat `blah': No such file or directory
> mv: cannot stat `blah.p': No such file or directory
> 
> even tried using `ls -c1` same thing.  Worse thing is I know I did this 
> before, so long ago, maybe I used Perl after all.  Hmm...
> 
> -
> : send the line "unsubscribe linux-admin" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-
: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux