FOR loop problem: Kindly Help

Hello Friends,

I have file called reference.txt which looks like below,

columns are been formed by delimiter "|" as shown. I am required to scan whole file line by line & compare 1st 2 columns with new name (ex. ferrari) & new version (2.1).

CODE PURPOSE: whnever new project formed compare if it already exists & compare if version updated.

My Code

By executing my code i am finding,

  1. its looping for 19 times instead of looping for only 3 times. & providing 3 output for 3 rows.

Kindly help. Thanks a lot.

Perhaps try something like this....

oldIFS="$IFS"
IFS='|'
while read f1 f2 etc
do
   echo do something with $f1 and $f2
done < reference.txt
IFS="$oldIFS"

Sir thanks a lot for this quick solution. It absolutely gonna help. But stay connected.. if i need some more help!!!

:slight_smile:

Thanks

Once i find PROJECT matched & project VERSION matched. I am supposed to update $f3 & $f4 (3rd & 4th field) of same file.

Example:
reference.txt

New Project with following variables (I have)

Reference.txt should look like follwing.

Code:

some how sed is not working for me there to replace lable. Do you have some logic to fit in this loop.

Please Help! Thanks :slight_smile:

People Please Help me out.
Thanks:)

Hi.

Use double quotes in this situation -- single quotes do not allow variable expansion:

sed 's/$f3/$LABLE/' # Lable Replaced

I suggest you look over some tutorials like BASH Programming - Introduction HOW-TO ... cheers, drl

sed "s/$f3/$LABle/"

cheers,
Devaraj Takhellambam