Help in assigning values to variables from the file

Hi! This might be a simple thing, but I'm struggling to assign values to variables from the file.

I've the following values stored in the file.. It consists of only two rows..

10
20

I want to assign the first row value to variable "n1" and the second row value to variable "n2"..
That is

n1=10
n2=20

How can I do this??

Try...

n1=$(head -1 file1)
n2=$(tail -1 file1)
1 Like

Thank you :slight_smile:

declare $(awk '{print "n" NR,$NF}' OFS=\= file)