This is my script. It print every row in the file with the number of row. Next i want to read which row user choosed and save it to some variable.
  I=1
    for ROW in $(cat file.txt)
    do
        echo "$I $ROW"
        I=`expr $I + 1`
    done
    read var
    awk 'FNR = $var {print}' file.txt
Then i want to to print / save the chosen row into the file.
How can I do this ?
when i echo $var it shows me properly the number. But when i'm trying to use this variable in awk, it print every line.
How to read the 'var' line from file?
And moreover, how to save this line in other variable?
Example file.txt
1 line1
2 line2
3 line3
4 line4
when i tap 3 i want to read third line from file.
 
     
     
     
     
    