I'm on RHEL 6 using BASH.
I'm trying to sort some lines in a file, by a number that is embedded in a field. The name of the file is word.txt.
This is the command I am using:
sort -n -k4 word.txt
This is the output I am getting, not in numerical order:
INSERT INTO area_names VALUES(124,'NewYork'); INSERT INTO area_names VALUES(125,'NewYork'); INSERT INTO area_names VALUES(12,'NewYork');
Obviously, the line with just "12" should be first.
The number after "VALUES(" can be of any length
How can I tell sort to sort on the number in between "VALUES(" and "," ?
I can fall back on a workaround of putting a white space after "VALUES(" in the data, but I would rather not do that unless that is the best option.