D
D
Dmitry Evgrafovich2014-05-05 22:27:40
linux
Dmitry Evgrafovich, 2014-05-05 22:27:40

How to use grep to print a match with a regular expression?

There is a binary file for two gigabytes (dump), you need to extract lines matching the pattern from it and save them to a text file. Tried
grep -P --regexp='PHPSESSID=(.+?);' dump.bin > result.txt
but as far as I understand, all the lines in which this regular expression occurs are written to the final file. I would like to get only what is contained in brackets.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2014-05-05
@Tantacula

You can add -o, then only parts of the lines that match the regular expression will be output.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question