Read multiple values into one variable

Hello everybody,

I am trying to assign multiple values from text into a single variable in bash.

Source TXT:

1 THIS IS THE ENTITY1 NAME1
2 THIS IS THE ENTITY2 NAME2
3 THIS IS THE ENTITY3 NAME3
  while read id entity name
     do
        printf "$id" "$entity" "$name"
done < "$sourceTXT"

In this example I want to assign "THIS IS THE ENTITY1" to $entity rather than "THIS"

Hope it is clear ..

Please use code tags as required by forum rules!

You can't. Unless you use different delimiters within the line. Workaround:

while read id A B C D name REST
     do entity="$A $B $C $D"
        printf "$id" "$entity" "$name"
     done < "$sourceTXT"
1 Like

Sorry for not following the rules.. That will help thank you