Skip to main content
edited body
Source Link
Rakesh Sharma
  • 859
  • 1
  • 5
  • 7

Store lines in separate containers depending on whether they need to move south or remain in place. Then when all lines have been looked at this way, print them in the desired order.

$ perl -ne 'push @{/_00[2468]$/ ? \@A : \@B}, $_}{print @B, @A' input.txt

You can do this with posix sed also:

$ sed -ne '
    /_00[2468]$/ s//&/w data2468
    //!p
    $r data2468
' input.txt

Store lines in separate containers depending on whether they need to move south or remain in place. Then when all lines have been looked at this way, print them in the desired order.

$ perl -ne 'push @{/_00[2468]$/ ? \@A : \@B}, $_}{print @B, @A' input.txt

You can do this with posix sed also:

$ sed -ne '
    /_00[2468]$/ s//&/w data2468
   //!p
    $r data2468
' input.txt

Store lines in separate containers depending on whether they need to move south or remain in place. Then when all lines have been looked at this way, print them in the desired order.

$ perl -ne 'push @{/_00[2468]$/ ? \@A : \@B}, $_}{print @B, @A' input.txt

You can do this with posix sed also:

$ sed -ne '
    /_00[2468]$/s//&/w data2468
    //!p
    $r data2468
' input.txt
deleted 3 characters in body
Source Link
Rakesh Sharma
  • 859
  • 1
  • 5
  • 7

Store lines in separate containers depending on whether they need to move south or remain in place. Then when all lines have been looked at this way, print them in the desired order.

$ perl -ne 'push @{/_00[2468]$/ ? \@A : \@B}, $_}{print @B, @A' input.txt

You can do this with posix sed also:

$ sed -ne '
    /_00[2468]$/!{
      p;ba
    }
    s/^/&/w data2468
    :a;$//!d;rp
    $r data2468
' input.txt

Store lines in separate containers depending on whether they need to move south or remain in place. Then when all lines have been looked at this way, print them in the desired order.

$ perl -ne 'push @{/_00[2468]$/ ? \@A : \@B}, $_}{print @B, @A' input.txt

You can do this with posix sed also:

$ sed -ne '
    /_00[2468]$/!{
      p;ba
    }
    s/^//w data2468
    :a;$!d;r data2468
' input.txt

Store lines in separate containers depending on whether they need to move south or remain in place. Then when all lines have been looked at this way, print them in the desired order.

$ perl -ne 'push @{/_00[2468]$/ ? \@A : \@B}, $_}{print @B, @A' input.txt

You can do this with posix sed also:

$ sed -ne '
    /_00[2468]$/ s//&/w data2468
   //!p
    $r data2468
' input.txt
Source Link
Rakesh Sharma
  • 859
  • 1
  • 5
  • 7

Store lines in separate containers depending on whether they need to move south or remain in place. Then when all lines have been looked at this way, print them in the desired order.

$ perl -ne 'push @{/_00[2468]$/ ? \@A : \@B}, $_}{print @B, @A' input.txt

You can do this with posix sed also:

$ sed -ne '
    /_00[2468]$/!{
      p;ba
    }
    s/^//w data2468
    :a;$!d;r data2468
' input.txt