When I create a Shell script and try to do this in a POSIX compatible way, sometimes I would need to read (only) certain lines of a file or a pipe.
In order not to end up in a construction of head an tail invokations and in order to output several blocks of data at one time I programmed a replacement for head and tail.
The first version was a slow shell skript, the second version is a faster awk program which has same functionality.
Programs' usage is explained inthe following examples:
Remark: Only use the program in a private scope; for further information please look at the imprint of this website.
# printf " %s\n" a b c d e f g | getline 2-3,3#-6 b c e f # printf " %s\n" a b c d e f g | getline 3#-6,2-3 b c e f # printf " %s\n" a b c d e | lines 2-3,3#-4 b c c d # printf " %s\n" a b c d e | lines --unique 2-3,3#-4 b c d # printf " %s\n" a b c d e | lines --unique 2-3,3#- b c d e #