home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!usc!rpi!fitzgb
- From: fitzgb@mml0.meche.rpi.edu (Brian Fitzgerald)
- Subject: Re: Changing file names
- Message-ID: <g1hy6sd@rpi.edu>
- Nntp-Posting-Host: mml0.meche.rpi.edu
- Organization: Rensselaer Polytechnic Institute, Troy, NY
- References: <ac#n06l.bosak@netcom.com>
- Date: Fri, 21 Aug 1992 06:07:57 GMT
- Lines: 35
-
- Jon Bosak writes:
- >
- >Suppose I have a directory containing files named, for example,
- >
- > xyz920815a ...
- >
- >...and so on. I want to change the names of these files to
- >
- > 920815a ...
-
- A wise system programmer at RPI decided that the campus user shell will
- be bash, regardless of the vendor platform (thanks, Scanner!). A bash
- solution (like the ksh solution posted by someone else.) is
-
- for i in xyz* ; do mv $i ${i#xyz} ; done
-
- To me, this is simple enough to type from memory without using aliases
- or shell scripts.
-
- For testing, I usually type
-
- for i in xyz* ; do echo mv $i ${i#xyz} ; done
-
- and look at the echo output. If it looks ok, I type ^echo to actually
- run the command. On the other hand, if the echo prints something
- unexpected, I just press the uparrow key, edit the command line, and
- try again.
-
- To changes suffixes, instead of prefixes, try, for example,
-
- for i in *.c ; do mv $i ${i%.c}.o ; done
-
- Bash is available for free from lots of places. Check archie.
-
- Brian
-