From owner-freebsd-questions Thu Jan 9 10:48:41 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BA9F037B434 for ; Thu, 9 Jan 2003 10:48:38 -0800 (PST) Received: from albatross.prod.itd.earthlink.net (albatross.mail.pas.earthlink.net [207.217.120.120]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0F83543ED8 for ; Thu, 9 Jan 2003 10:48:38 -0800 (PST) (envelope-from parv_fm@mailsent.net) Received: from sdn-ap-035dcwashp0328.dialsprint.net ([65.179.105.74] helo=moo.holy.cow) by albatross.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 18Whiy-0004EW-00; Thu, 09 Jan 2003 10:48:17 -0800 Received: by moo.holy.cow (Postfix, from userid 1001) id 9D686AF08; Thu, 9 Jan 2003 13:51:08 -0500 (EST) Date: Thu, 9 Jan 2003 13:51:08 -0500 From: parv To: Stijn Hoop Cc: Rob , "BigBrother (BigB3)" , Duncan Anker , freebsd-questions@freebsd.org Subject: Re: Renaming files with spaces in the name to files without spaces.. Message-ID: <20030109185108.GA69391@moo.holy.cow> Mail-Followup-To: Stijn Hoop , Rob , "BigBrother (BigB3)" , Duncan Anker , freebsd-questions@freebsd.org References: <20030108175539.W65616@bigb3server.bbcluster.gr> <200301091519.h09FJIK7000567@goo.0x7e.net> <20030109163044.GG938@pcwin002.win.tue.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030109163044.GG938@pcwin002.win.tue.nl> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG in message <20030109163044.GG938@pcwin002.win.tue.nl>, wrote Stijn Hoop thusly... > > On Fri, Jan 10, 2003 at 01:49:18AM +1030, Rob wrote: > > > If you want to do it for all files in a directory: > > > > > > # for file in *; do mv "$file" `echo $file | sed -e 's/ /_/g'`; done ^ ^ ^ ^ > > > > > But if you do this, won't the spaces be mistaken for filename > > separators? > > No, he has quotes around his $file, and the `` part replaces > spaces, so this should work. notice that $file is not enclosed in the sub shell (in between ``) as an argument to echo. if the $file happens to have end blanks, they will be eaten up. try... f=' p q r '; echo $( echo $f | sed 's/ /_/g' ) ...output /should/ have been '_p_q_r_', but is 'p_q_r'. > $ touch "a b" c > $ for i in *; do echo "arg $i endarg"; done ^ ^ ^ ^ > arg a b endarg > arg c endarg notice that you have enclosed the string to echo in double quotes, which preserves the spaces. - parv -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message