I would like to ask one qustion: I have something like this. WEDI_RC is a txt file and I want read it line by line, take first column and store it to variable "name". When I echo 4th line it successfully write first column ($1). Then I want to compare it with $list, if it matched then add it to $list and write. It should write just one time every name. See example below:
Input:
file1 1234 5667
file1 1234 4566
file1 1234 23456
file1 1234 23467
file2 1234 23456
file3 1234 12345
Output:
file1
file2
file3
My code:
list=""
while read -r line
do
name=$(echo $line | awk -F'[ ]' '{print $1}')
echo $name
if [ "$name" = "$list" ]; then
echo $name
list=$'$list\n$name'
echo "$list"
fi
done < $WEDI_RC