Imagine an output of a command like4444455555111112222233333how can I yank the first N lines (first two in the example above) and append them at the end, but without using temp file (so only using pipes)?1111122222333334444455555Something along the lines of | sed -n '3,5p;1,2p' (which obviously doesn't work as sed doesn't care about the order of the commands).
Move first N lines of output to end without using temporary file
command line;text processing
Just copy those lines to the hold buffer (then delete them) and when on last line append the content of hold buffer to pattern space:some command | sed '1,NUMBER{           # in this rangeH                                       # append line to hold space and1h                                      # overwrite if it's the 1st lined                                       # then delete the line}$G'                                     # on last line append hold buffer contentWith gnu sed you could write it assome command | sed '1,NUMBER{H;1h;d;};$G'Here's another way with ol' ed (it reads the output of some command into the text buffer and then moves lines 1,NUMBER after the la$t one):ed -s <<INr ! some command1,NUMBERm$,pqINNote that - as pointed out - these will both fail if the output has less than NUMBER+1 lines. A more solid approach would be (gnu sed syntax):some command | sed '1,NUMBER{H;1h;$!d;${g;q;};};$G'this one only deletes lines in that range as long as they're not the last line ($!d) - else it overwrites pattern space with hold buffer content (g) and then quits (after printing the current pattern space).