I want to rename the file as SCHEDULE_REQUEST_TestCase.log
I know that mv command can be used to rename the file, and read or head can be used to read the first line of the file, but i want to remove the text before SCHEDULE and dots after TestCase.
I want to perform this for all the files i have generated i don't really get how to do that and eliminate the unwanted text from the first line? I guess sed or awk can be used to eliminate the text I have started shell scripting like five days ago any help would be greatly appreciated.
The following is totally untested, but should come close to what you want. If the lines printed out by this look like the mv commands you hope to run, remove the echo from the awk script and run it again to actually remove the files:
but the awk nextfile command is not present in all versions of awk and you didn't bother to tell us what operating system or shell you're using (so we can't rely on it being available in your environment).
Thanks Don Cragun, it is prints what i wanted it to look like . I am using bash shell, I have used nextfile displayed the same thing.
but how can do the same thing for the all the 14 files I have given that i standing on the current level , without having to do this manually for the every file
all the files are named similarly like
test-000000
test-000001
test-000002
I know i should loop through but was not sure how to increment the loop to go to next file, how can i achieve this?
Don Cragun's little awk script does exactly that - loop through ALL test-?????? files around, where ?????? matches the file names the sample numbers you post: 000000 , 000001 , 000002 , etc.
If - as he explains - the echo command is removed, and the schript's output is piped through sh , all your test files should be renamed according to your spec. That is - if all files contain DIFFERENT strings as $4 in their first line. If not, files with lower numbers might be overwritten by the ones with higher number and identical $4.
EDIT: To avoid that problem, consider this small adaption of Don Cragun's script: