Date: Mon, 25 Sep 2000 15:59:55 +0200 From: Willem Brown <willem@brwn.org> To: "Dimitri T." <midios4@hotmail.com> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: how do I get rid of that prefix?! Message-ID: <20000925155955.Z50534@snoopy.brwn.org> In-Reply-To: <F2328k69RKLpgTFur2i00003f62@hotmail.com>; from midios4@hotmail.com on Mon, Sep 25, 2000 at 12:36:43PM %2B0000 References: <F2328k69RKLpgTFur2i00003f62@hotmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, How about...(tcsh) --- CUT --- #!/bin/tcsh # # delprefix.csh -- rename a file after removing a prefix from the # file name. # set files = (abc abc. abc.. abcd abcd.file1 abcd.file2 abcd.file3 abcd.file4.abcd) # Touch the files just to make sure they do exist before hand for the # sake of the demonstration. touch $files foreach file ($files) # Use the sed command to remove the prefix from the name # of the file. set newfile = `echo $file|sed -e 's/^abc//'` # Check to make sure that after the prefix was removed, # newfile is not "." or ".." (current and previous directories) # and that newfile is not empty ("") if ( $newfile != ".." && $newfile != "." && $newfile != "" ) then mv $file $newfile endif end --- CUT --- > ls abc abc. abc.. d d.file1 d.file2 d.file3 d.file4.abcd This worked for me, it might not work for anybody else. It is also the longest tcsh script I've ever written and is not perfect and most probably an overkill. On Mon, Sep 25, 2000 at 12:36:43PM +0000, Dimitri T. wrote: > hello everybody, > > I have some hundreds of files with a filename starting with a specific > prefix (lets say 'abc') and I want to rename them and get rid of this > prefix. How do I do that? > > I've been experementing and actually managed to add prefices, delete sufices > but still cannot figure how to DELETE PREFECES! (it's driving me crazy, u > know.. Aaaargh!!) ~%^@ > > Any help is welcome .. > > bye, > dimitri > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > Share information about yourself, create your own public profile at > http://profiles.msn.com. > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > Best Regards Willem Brown -- /* =============================================================== */ /* Linux, FreeBSD, NetBSD, OpenBSD. The choice is yours. */ /* =============================================================== */ I am so optimistic about beef prices that I've just leased a pot roast with an option to buy. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000925155955.Z50534>