rename file according to one parameter not working
by Pyrrhus6 from LinuxQuestions.org on (#5E414)
Hello,
I am a beginner in Unix and I use Ubuntu.
I try to write a script in bash that would add the suffix -old to the files whose type is the parameter entered by the user. For instance, I would like all *.txt to be renamed *.txt-old. I tried multiple scripts, the last one being in the file attached (I am sorry, but [IMG] code seems to be off, I don't know why, I tried to change my options)
When I activate the script with ./multiplerename.sh *.txt, it modifies only one file in my directory, file.txt , and this file becomes *-old !
I read many things on the internet, but couldn't find an answer to my specific issue. I hope you can help me, because I have been working on it for many hours and I begin to despair.
Thank you for your help !
Pyrrhus6
Attached Thumbnails


I am a beginner in Unix and I use Ubuntu.
I try to write a script in bash that would add the suffix -old to the files whose type is the parameter entered by the user. For instance, I would like all *.txt to be renamed *.txt-old. I tried multiple scripts, the last one being in the file attached (I am sorry, but [IMG] code seems to be off, I don't know why, I tried to change my options)
When I activate the script with ./multiplerename.sh *.txt, it modifies only one file in my directory, file.txt , and this file becomes *-old !
I read many things on the internet, but couldn't find an answer to my specific issue. I hope you can help me, because I have been working on it for many hours and I begin to despair.
Thank you for your help !
Pyrrhus6
Attached Thumbnails