0

I am having problem in reading data from a file into a variable.

value=$(config.txt)
echo "${value}

It works fine on my terminal. But not when i write it into a bash file and compile it. The echo "$value" lists right on terminal.But running as bash file, it is empty

codeforester
  • 39,467
  • 16
  • 112
  • 140
sony
  • 1

1 Answers1

0

Correct way of using this would be :

value=$(cat config.txt) 

Or

value=$( < config.txt) 
P....
  • 17,421
  • 2
  • 32
  • 52
  • Thanks I used `value=$( < config.txt) `. It works fine when I used `echo ${value}`. But when I run a for loop. I am getting last file name only. `for p in ${value}; do ls -Art $p done`. I am getting No such file or directory for all but last entry of the list. Please help. – sony Feb 16 '17 at 14:30