I'm trying to find a fast and easy method for searching a line in a file with another string.
Say I have this file:
line nr 1
another line over here
here's another line
something else
and more
Now I want to get the line that compares best to, for example, a line here
. Which in this case would be another line over here
. Note that here's another line
is less alike and I don't need this.
Is there a way to sort the file or grep the line with the most matching words or best matching pattern? *edit: basically like what a search engine would do.
Something like: $ cat file | sort --compare 'string'