Problem while assign string (words with tab) to a variable

Hi,

I have a String(words with tab space) in a file ->file1.txt

 0xxxx    11      test  $aa$   8.43

when i read the file and assign to variable

  value=$(cat file1.txt)
              echo $value
 

i get the output without tab spaces.

  0xxxx 11 test $aa$ 8.43 

How to assign string to variable with tab spaces.

Please Suggest me,

Thank You & Regards
Nanthagopal A

Try this:

value="$(cat file1.txt)"
echo "${value}"
1 Like

Actually the quotes are not necessary for the assignment:

value=$(cat file1.txt)

--
or if it is always just one line:

read value < file1.txt

or

IFS= read -r value < file1.txt 

to preserve leading and closing spaces and backslash characters..

2 Likes