V
V
V Federoff2016-05-30 21:20:01
Perl
V Federoff, 2016-05-30 21:20:01

How to find a matched line in a file and print all lines that are after it?

We have, for example, a file with the following content:

AAA
BBB
CCC
DDD
EEE
GGG

There is a task to find the line CCC in it and only the rest of the contents of the file.
How to implement this in Perl?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vaut, 2016-05-30
@vaut

perl -ne '$print=1 if /pattern/; print if $print'
I was told that there is a more elegant solution:
perl -ne 'print if /pattern/ .. eof'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question