home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!gatech!rpi!psinntp!psinntp!dg-rtp!hobbit!hunt
- From: hunt@dg-rtp.rtp.dg.com (Greg Hunt)
- Subject: Re: Changing file names
- Message-ID: <1992Aug20.202625.16938@dg-rtp.dg.com>
- Sender: hunt@hobbit (Greg Hunt)
- Date: Thu, 20 Aug 92 20:26:25 GMT
- Reply-To: hunt@dg-rtp.rtp.dg.com
- References: <ac#n06l.bosak@netcom.com>
- Organization: Data General Corp., Research Triangle Park, NC
- Lines: 39
-
- In article <ac#n06l.bosak@netcom.com>, bosak@netcom.com (Jon Bosak) writes:
- >
- > Here's a problem that must be very common but doesn't seem to get
- > discussed in books for Unix novices.
- >
- > Suppose I have a directory containing files named, for example,
- >
- > xyz920815a
- > xyz920815b
- > xyz920816
- > xyz920817
- > xyz920818a
- > xyz920818b
- >
- > ...and so on. I want to change the names of these files to
- >
- > 920815a
- > 920815b
- > 920816
- > 920817
- > 920818a
- > 920818b
- >
- > ...and so on. Simple, right? Just chop off the first three
- > characters and there you are. But how is it done?
-
- Here's one way:
-
- #!/bin/sh
- for Tmp in xyz*
- do
- mv $Tmp `echo $Tmp | awk '{print substr ($1, 4)}'`
- done
-
- --
- Greg Hunt email: hunt@dg-rtp.rtp.dg.com
- DG/UX Core Development
- Data General Corporation
- Research Triangle Park, NC, USA These opinions are mine, not DG's.
-