From mboxrd@z Thu Jan 1 00:00:00 1970 From: Agus Budy Wuysang Subject: Re: Stupid spaces Date: Fri, 13 Feb 2004 13:51:46 +0700 Sender: linux-admin-owner@vger.kernel.org Message-ID: <402C7402.3030608@fasw.co.id> References: <5.2.1.1.0.20040212130333.00b0f4a0@mustang> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5.2.1.1.0.20040212130333.00b0f4a0@mustang> List-Id: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: linux-admin@vger.kernel.org Cc: Scott Taylor Scott Taylor wrote: > Hello all, > > I've done this before, but so long ago I can't find it again. I have a > bunch of files with spaces in them and I want to rename them with the > spaces removed. > > I have a rename command that came with RH7.2 but doesn't do the job > rename 's/\ //g' * > does nothing in bash rename doesn't work like DOS' rename, but: rename old_pattern new_pattern files... > So I wrote a script many moons ago to do this but I can't remember which > server it was on, let alone how I did it. Something with tr and mv > methinks. > > anyone? If you're lucky enough to have bash V2, use (faster): for f in *;do mv -i "$f" "${f// /}";done otherwise: for f in *;do mv -i "$f" "$(echo $f|tr -d ' ')";done If your actual intention of getting rid of spaces were to get around difficulties in shell command globbing/parsing, you should learn more about "find -print0" & "xargs -0" instead. -- +-R-| Mozilla 1.6 Gecko20040116 |-H-| Powered by Linux 2.4.x |-9-+ |/v\ Agus Budy Wuysang MIS Department | | | Phone: +62-21-344-1316 ext 317 GSM: +62-816-1972-051 | +------------| http://www.fasw.co.id/person/supes/ |-------------+