I'm trying to write a bash script that takes an input stream and sorts lines containing a keyword to the top.
Starting point:
$ cat file
cat
dog
mouse
bird
cat and mouse
lorem
ipsum
Goal:
$ cat file | sort-by-keyword mouse
mouse
cat and mouse
cat
dog
bird
lorem
ipsum
I've tried to implement this using sort but failed. Is another tool/way I'm not aware of?