-1

I have a .txt File where there is data in it like

Ram
Raj
Viraj

I want to pass only first value Ram to a variable so that I can use its value further in the Linux command.

I have code which works but partially

head -1 demo.txt => gives me first value Ram

But How do I pass that value to a variable

Like this

$value head-1 demo.txt
$value = Ram

Not working ......

jww
  • 97,681
  • 90
  • 411
  • 885
  • 4
    Possible duplicate of [How do I set a variable to the output of a command in Bash?](https://stackoverflow.com/q/4651437/608639), [How to assign the output of a Bash command to a variable?](https://stackoverflow.com/q/2314750/608639), etc. – jww May 22 '19 at 12:39

1 Answers1

0

try this:

value=$(head -1 demo.txt)
UtLox
  • 3,744
  • 2
  • 10
  • 13