in reply to manipulating file contents
or maybe you want a one-liner:while(<>){ print "$1;\n" if /^(Key [0-5] 0x[\da-f]{14})/i; } while( my $line = <>){ if( my ($match) = $line =~ /^(Key [0-5] 0x[\da-f]{14})/i ){ print "$match;\n"; } }
This will change "file.txt".perl -ni -le 'print "$1;" if /^(Key [0-5] 0x[\da-f]{14})/i' file.txt
|
|---|