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
  • 34,080
  • 14
  • 96
  • 122
sony
  • 1

1 Answers1

0

Correct way of using this would be :

value=$(cat config.txt) 

Or

value=$( < config.txt) 
P....
  • 14,772
  • 2
  • 24
  • 42
  • 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