Re: A challenge for UNIX wizards
Article: 7875 of alt.hackers From: and1000@thor.cam.ac.uk (Austin Donnelly) Newsgroups: alt.hackers Subject: Re: A challenge for UNIX wizards Date: 25 May 1995 11:29:28 GMT Organization: University of Cambridge, England Lines: 29 Approved: and1000@cam.ac.uk Message-ID: 3q1pmo$8nc@lyra.csx.cam.ac.uk Reply-To: and1000@cam.ac.uk NNTP-Posting-Host: hammer.thor.cam.ac.uk Status: RO
In article <3q185g$3je@lll-winken.llnl.gov>, Sam Trenholme <set@oryx.llnl.gov> wrote: > >ls | awk 'BEGIN{FS="."}{print "mv "$0" "$1".1"}' > l;chmod 700 l;l;rm l > >(The above made a list of files, foo.man, bar.man, etc. have the names >foo.1, bar.1, etc) But it won't do too well for files like "foo.bar.man" :) You can use the build-in features of bash to do something like this: ---------- cut cut cut ---------- #!/bin/bash # Convert *.man to *.1 from=.man to=.1 for i in *$from; do base=${i%$from} mv $i $base$to done ---------- cut cut cut ---------- Austin _ ___ ________ _ _ ________________________________________________ / _ \ _ _ __| |_(_)_ _ Austin Donnelly | _ | || (_-< _| | ' \ Pembroke College, Cambridge |_| |_|\_,_/__/\__|_|_||_| and1000@cam.ac.uk ---------------------------------------------------------------------