bash - Print last line of text file -
i have text file this:
1.2.3.t 1.2.4.t complete i need print last non blank line , 2 line last 2 variable. output should be:
a=1.2.4.t b=complete i tried last line: b=awk '/./{line=$0} end{print line}' myfile have no idea a.
awk rescue!
$ awk 'nf{a=b;b=$0} end{print "a="a;print "b="b}' file a=1.2.4.t b=complete or, if want real variable assignment
$ awk 'nf{a=b;b=$0} end{print a, b}' file | read b; echo "a="$a; echo "b="$b a=1.2.4.t b=complete you may need -r option read if have backslashes in values.
Comments
Post a Comment