Assiging to a variable after cutting from the input line

Hi all,

I am reading from the file having entries like below

 
111.ABC.POT
6477.YHT.OIT

Now I need to read each line and cut each line seperated by dot and print into the file .

I tried below and it is not working . Please help

while read READLINE
do
     eval LINE=${READLINE}
     echo $LINE
     Field5=`echo $LINE|cut -d. -f1`
     echo "${Field1} ,${Field2},${Field3},${Field4},${Field5},${Field6}" > FINAL2.txt
done < FINALFILE.txt

Thanks
DJ

I am slightly confused as to what you are trying to do.

Can you please provide some sample output?

+ please use code tags

How can you want to cut line separated by dots when your file sample has not cases of such...
As of post#2 What you gave us and explained is far from being clear, especially when you have not given a example of expected output so we can figure out what you ment
I am dubious looking at your code...

Maybe you can set IFS to split the file during reading, then you do not need cut .
For example, read FINAL.txt, echo the new lines, and redirect the whole loop to FINAL2.txt

while IFS="." read f1 f2 f3
do
  # compose a new line and print it
  echo "$f1.$f2.$f3.$f1"
done < FINAL.txt > FINAL2.txt
1 Like