I am trying to sort a list of names followed by another string such as:
John Doe
AVAIL
Sara Doe
CALL
Jim Doe
AVAIL
I am trying to sort th
not directly, but you can use some intermediate form like this. i am assuming that your value (CALL, AVAIL, etc.) is limited. otherwise you need to use patterns that are more complicated, but it can be done. actually anything can be done in bash :-)
cat sorting | sed -n '1h; 1!H; ${ g; s/\nCALL\n/::CALL::/g; s/\nAVAIL\n/::AVAIL::/g ; s/\nAVAIL/::AVAIL::/g p }' | sort | sed "s/::/\n/g"
Jim Doe
AVAIL
John Doe
AVAIL
Sara Doe
CALL