jeudi 25 août 2016

Grab text between identifiers while escaping a hyphen "-" in perl

I'm attempting to grab the text of a line after the "A. " until the end of the line. I've tried:

perl -ne 'print if /A[.] /../\R/' test.txt > test2.txt

Where I thought the "\R" would match the end of a line. However when the line contains a hyphen "-", the output does not stop at the end of the line, instead prints the next lines until the hyphens stop.

An example line from test.txt that fails is as follows:

A. -rw-r-----, -r--------

The intended test2.txt output is:

-rw-r-----, -r--------

Aucun commentaire:

Enregistrer un commentaire