View Single Post
  #1 (permalink)  
Old 07-11-09, 13:55
anant123123 anant123123 is offline
Registered User
 
Join Date: Nov 2007
Posts: 21
shell script to read the fields of text file line by line

Hi,

I need to read a text file from shell script line by line and copy the feilds of each line.

Below is the complete requirement.

I've text file which contains ...

pgm1 file11 file12 file13
pgm2 file21 file22
pgm3 file31 file32 file33


I'll give input as pgm1/pgm2/pgm3 etc.

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.



Thanks,
Reply With Quote