Q:

How to get specific line from output and save it in one variable?

when i run this command
user@ubuntu:~$ ./2input1output Jojo Ar Dublin

it give me this output
Your First Name: Jojo 
Your Last Name : Ar 
Your Hometown : Dublin
Thank you, Jojo Ar From Dublin,
Welcome to Stackoverflow

Now i need to display the 4 and 5 line from that output then save it in one variable for example i call variable MESSAGE, i have try this
user@ubuntu:~$ (sed -n 4,5p ./2input1output)

but it give me this output
echo"Thank you, $1 $2 From $3,
Welcome to stackoverflow"

A:

Your command is actually working as expected; you are asking sed to return lines 4 and 5 from the file "2input1output". As you can see, the positional arguments (i.e. $1, $2 and $3) are returned because that is what is in the script. 
What you need to do is actually run the script first in order to get the desired output (STDOUT) and then pipe that to the stream editor (sed). So, in one hit, to save the desired content to a variable:
$ MESSAGE=$(./2input1output Jojo Ar Dublin | sed -n 4,5p)

Please remember that if you need to preserve newline characters when accessing the variable, wrap it in double quotation marks first.

