Sam Trenholme's webpage
This article was posted to the Usenet group alt.hackers in 1995; any technical information is probably outdated.

Re: A challenge for UNIX wizards


Article: 7873 of alt.hackers
Newsgroups: alt.hackers
From: tim@acm.org
Subject: Re: A challenge for UNIX wizards
Message-ID: tim.801387391@canon.co.uk
Sender: tim@canon.co.uk
Organization: Not !NET-CRE
Date: Thu, 25 May 1995 07:36:31 GMT
Approved: tim@canon.co.uk
Lines: 26
Status: RO

set@oryx.llnl.gov (Sam Trenholme) writes:

|Ok guys, is there a way of doing this without using a temporary file:
|
|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)
|
|The following didn't work:
|
|eval `ls | awk 'BEGIN{FS="."}{print "mv "$0"
"$1".1"}'`

You're just missing a semi-colon to separate the individual mv commands, ie:

eval `ls | awk -F. '{print "mv "$0" "$1".1;"}'`

Alternatively:

perl -e 'for(@ARGV){($n=$_)=~s/\.man$/.1/;rename($_,$n);}' *.man

Bigger and faster.

Tim
--
Tim F O'Donoghue <tim@acm.org> +44-1483-448855 !TFO



Parent

Back to index