Hi, i m trying to loop a variable value, Basically i m reading variable value from an input file and using in rest of the program. Bu my problem is when i first time read value and assign to variable it works fine, but in second read it concatinate second value to first value with a LF. I want to use one value at a time. Here is what i am doing
Your error is quite obvious. Your loop variable is 'i', and as the value of i increases, head -${i} returns more and more lines. Let me explain.
At your first pass through the loop, the value of i is 1. You get the first line. So far so good. At the second pass the value of i becomes 2 and head -${i} becomes head -2, which returns the first two lines.. this will continue as long as the value of i increases.
If you want to read the value of carrier id from the file into variable carrier_id, you have to use
while read carrier_id;do
..
# do your stuff here
..
done < ${cnt_path}mpd_rxsh_carrier_id.dat