the shell script has to read the text file and if the input given is pgm1 then the shell script shoud copy the file to some directory.
file directory is common for all the files.
when the input is pgm2 then the shell script should have statements for copying file21, file22 etc and so on.
I tried the file reading with WHILE DO and FOR LOOP and used CUT option to differentiate the feilds. But I'm getting all the records with the looping and I'm unable to cut exactly as the number of files for each program differs.
Can anybody suggest code which completes my requirement?
I'm using KSH.
Assumed "temp.txt" is the input files.
Assumed "new_directory" is the directory to copy to.
Assumed max. number of files to copy is 7.
If not increase/decrease $2......$7.
Do not use $0 or $1.
Take care of error trapping and consider writing into a script.
Ex: What if egrep finds nothing?
set `egrep '^pgm' temp.txt` && cp $2 $3 $4 $5 $5 $7 new_directory
(Note the && in the above line)