Sorry for the poor title. What I am trying to do is the following. I have a directory with (say) a 1000 files with names of the form
Foo_bar_1,...,Foo_bar_1000. I would like to remove the 'bar' from each file name. For a single file this is easy, e.g.:
mv Foo_bar_1 Foo_1.
Obviously I could process all files in this way using a loop. However, I am wondering if there is an easy way to do this without a loop using the
mv command an regexps. I can match any source file with the expression
Foo_bar_*. Is there any way I can now "access" the text that was matched with
What I want to write is something like
mv Foo_bar_* Foo_*, where the second
* in the destination file should be equal to the string that was matched with
* in the source file. How can this be done?