The situation is like this. There are many different file name in this directory.
I have to grep all the file that the name start with "PTWO" and rename it to COM with the current date.
This is the script that I have done and it hit an error..
#!/bin/bash
But my biggest problem right now is how to grep all the filename that start with PTWO and change them to the same new name. There are also other filename in the directory.
Let me clear the situation to you. In folder A there are many different files with different names.
I need to grep all the files in that folder which the name start with "PTWO" and rename them to "COM" with the current date.
Two different files can't have the same name. It will overwrite the exiting one when you try to move another one with the same name. That is why I am suggesting you have filenames like below. If that works out for you, you can use my old code with the i.
COM_1_20090412.txt
COM_2_20090412.txt
Thanks guys for all the script.
After reviewing all of your script, I have choose the one from alepi..
And my program has work after customizing the script a little bit..
Thank You so Much!! Although I am a newbie in shell scripting, it is very enjoyable doing it because of you guys..
Anybody know on how to use shell script to insert all the data in the database??
Let me use the example from the situation before this :
After I have rename all the file name that start with the word "PTWO", I want to keep track all the previous file name(before the renaming process) and the latest filename (after it has been rename).
So I want to create a table that have 2 column which are "previous file name" and "new file name".