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 <<EOF <{echo $i} >[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