Linux shell scripts, how can I rename all the files in the working directory to append their name?

Question by b down: Linux shell scripts, how can I rename all the files in the working directory to append their name?
for example, i have these files in my directory:
text1
text2
text3

and i’d like to rename them all:
text1.something
text2.something
text3.something

i’d like to use the mv command or cp if possible. i’m using fedora core2.

thanks

Best answer:

Answer by adaviel
bash:
for f in text* do ; mv -i $ f $ f.something ; done

Try it in a test directory first, you can get messed up trying to move things to themselves, or if one of your pattern matches is a directory, or you match “..”

What do you think? Answer below!

Get the book now