I need to find the last column from a variable that contains some fields. I need to write something like:
if [ #the last column = "R" ];
then
value=`echo "'$value'"`
fi
Is it possible?
With awk
you can try:
awk '$NF=="R"' <<< "$var"
$ var="this is a var with last as R"
$ awk '$NF=="R"' <<< "$var"
this is a var with last as R
$ var1="This should not be printed"
$ awk '$NF=="R"' <<< "$var1"
$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With