I want to extract the last column from lines that look like:880.952         NAV_Y                uSimMarine      -146.17516The number isn't always negative, and isn't a fixed length (i.e. doesn't always have the same number of decimal places).This gets me most of the way there:grep -E \-?[[:digit:]]{1,3}\.[[:digit:]]{0,5}Except it also matches the number in the first column.If I change this to include the end of line to eliminate the first column matches:grep -E [[:digit:]]{1,3}\.[[:digit:]]{0,5}$I get no matches, which I don't understand.What am I missing here?
Regex to grep filler followed by signed float
grep;regular expression
Anchor the expression to the end of the line:grep -E \-?[[:digit:]]{1,3}\.[[:digit:]]{0,5}$If you add the PCRE option of -o to return only the captured group, you will see that your example matches and returns the desired match:grep -oE (\-?[[:digit:]]{1,3}\.[[:digit:]]{0,5}$)-146.17516Too, to catch matches for lines in a file with optional, trailing whitespace, simply add \s* as:grep -oE (\-?[[:digit:]]{1,3}\.[[:digit:]]{0,5}\s*$)