home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!pipex!warwick!cudcv
- From: cudcv@warwick.ac.uk (Rob McMahon)
- Subject: Re: Changing file names
- Message-ID: <wfgpbc1j@csv.warwick.ac.uk>
- Sender: news@csv.warwick.ac.uk (Network news)
- Nntp-Posting-Host: shark
- Organization: Computing Services, Warwick University, UK
- References: <ac#n06l.bosak@netcom.com> <31810002@hpcuhe.cup.hp.com> <1992Aug21.135128.20589@news.eng.convex.com>
- Date: Sat, 22 Aug 1992 15:11:38 GMT
- Lines: 40
-
- In article <1992Aug21.135128.20589@news.eng.convex.com> tchrist@convex.COM
- (Tom Christiansen) writes:
- >:for i in `ls`
- >:do
- >: echo $i | sed s/xyz// >j
- >: mv $i `cat j`
- >:done
- >:rm j
- >
- >Process pig. Why not
- >
- > mv $i `echo $i | sed 's/^xyz//'`
- >
- >Also, your method is going to earn you a lot of
- >
- > mv: foo and foo are identical
- >
- >errors.
-
- Minor critism :-) you failed to criticise the "for in in `ls`" when he could
- have done "for i in *", or in this case "for i in xyz*".
-
- I think we've come down to
-
- for i in xyz*
- do
- mv "$i" "`echo \"$i\" sed 's/^xyz//'`"
- done
-
- Oops. I seem to have slipped another critism in (not enough quotes). I hate
- scripts that can't deal with arbitrary filenames. This is one of the good
- points of {,t}csh, with its $var:q.
-
- Cheers,
-
- Rob
- --
- UUCP: ...!mcsun!uknet!warwick!cudcv PHONE: +44 203 523037
- JANET: cudcv@uk.ac.warwick INET: cudcv@warwick.ac.uk
- Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England
-