From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4A297A41.2070803@Princeton.EDU> Date: Fri, 5 Jun 2009 16:04:17 -0400 From: Martin Harriss User-Agent: Thunderbird 1.5.0.12 (X11/20090324) MIME-Version: 1.0 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [9fans] simple question: multiple rename Topicbox-Message-UUID: 055d9066-ead5-11e9-9d60-3106f5b1d025 Rudolf Sykora wrote: > Hello, > > I realized I cannot come up with a simple solution for the following. > I want to rename all the files whose names end with _g_b to just _g, > e.g. hello_g_b should be renamed to hello_g. > I simply don't know an easy way. > [the opposite way is simple: for(i in *_g) mv $i $i^_b ] > I only think about so complicated ways like > > for(i in *_g_b) { > s = `{sam -d <[2] /dev/null > 1s/(.+)_g/\1 > p > EOF > } > mv $i $s > } > > which describes my idea, but doesn't work, actually. (btw. how can one > correct it?) > > Thanks > Ruda > sed is your friend: s=`{ echo $i | sed -e 's/_g_b/_g/' } Martin