home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.misc
- Path: sparky!uunet!mcsun!Germany.EU.net!rz.uni-hildesheim.de!agsc!rubikon.han.de!toad
- From: toad@rubikon.han.de (Peter Cleve)
- Subject: Re: How to add a suffix to a bunch of files?
- Keywords: shell, script, files, names
- References: <1992Sep3.213646.26527@msc.cornell.edu>
- Organization: Rubikon Rethen BRD
- Date: Sat, 05 Sep 92 17:18:05 GMT
- Message-ID: <1992Sep05.171805.4769@rubikon.han.de>
- Lines: 30
-
- In <1992Sep3.213646.26527@msc.cornell.edu> dchin@tamar.msc.cornell.edu (David W. Chin) writes:
-
- >I have occasion to add suffices on a whole bunch of files, like a .1 suffix on
- >all files in cat1 (just an example). What's an elegant way to do it?
- >The one I thought of was:
-
- >#!/bin/sh
- >cd cat1
- >for X in `ls -1`
- > do
- > eval "mv $X $X.1"
- > done
-
- How about
-
- for i in *; do
- mv "$i" "$i.1"
- done
-
- or (with arguments)
-
- for i in $@; do
- mv "$i" "$i.1"
- done
-
- By
-
- --
- Peter Cleve, Hildesheimer Str. 316, 3014 Laatzen 3, Tel. 05102/1854 (Voice)
- Energiesparen ist das moralische Aequivalent zum Krieg. (Jimmy Carter)
-