Using Raku (formerly known as Perl_6)
raku -pe 'get;' file
Sample Input:
Data inserted into table. Total count 13
No error occurred
Data inserted into table. Total count 45
No error occurred
Data inserted into table. Total count 14
No error occurred
Data inserted into table. Total count 90
No error occurred
Sample Output:
Data inserted into table. Total count 13
Data inserted into table. Total count 45
Data inserted into table. Total count 14
Data inserted into table. Total count 90
There's already an answer using Raku from @cuonglm, which uses the one-liner raku -ne '.say if ++$ % 2'
. Above is a different approach using Raku's get
routine instead. In combination with the -pe
(autoprinting) command-line flags, Raku's get
routine advances the readline-cursor by a line, which (because -pe
prints return values not the $_
topic variable) results in that line get
-ting discarded. Only the first, third, fifth, etc. lines are printed.
Need to print the second, fourth, sixth lines, etc. instead of above? Just use Raku's -ne
command-line flags. Here Raku's get
routine advances the readline-cursor by a line, and then .put
is called, giving the following output:
~$ raku -ne 'get.put;' file
No error occurred
No error occurred
No error occurred
No error occurred
https://raku.org
grep -v "No error occurred" file
this command should work... what @paul has answered. In the output file, there will be no lines containing "No error occurred" this part.