procmail
[Top] [All Lists]

moving first line to end in sed

2000-06-30 14:35:41
Bart wrote,

| This moves the first line to the end:
| 
|       sed -n -e 1x -e 2,\$p -e \$x -e \$p

Since almost every line is printed, it's more efficient to forgo -n and then
stop the one line that isn't printed than to force all those that are, I
should imagine:

       sed -e 1h -e 1d -e \$G

In fact, even with -n, it can be done in three instructions:

      sed -ne 1h -e \$G -e 2,\$p
or
      sed -ne 1h -e \$G -e 1\!p

where the exclamation point is escaped for Dallman and other csh people.

| Or if you have a modern sed,
| 
|       sed -n '1x;2,$p;$x;$p'

Or if you have a modern sed,

       sed '1h;1d;$G'


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail