Sample Header Ad - 728x90

GREP PCRE RegExp: match desired line, then match the number, then remove the commas to match digits only

0 votes
2 answers
56 views
With the help of https://regexr.com/ I'm trying to understand and learn grep -P. So far I managed to get this result:
$ cat Dogtooth\ \[2001\,\ Lanthimos\ Yorgos\].mp4.info
Filename:               Dogtooth [2001, Lanthimos Yorgos].mp4
Title:                  Κυνόδοντας
File size:              4,240,762,886 bytes
Video duration:         5,839 seconds
I'm successful in getting the value of *Filename* with ^F\w+\:\s+\K.+\.\w{1,4}$
$ grep -o -P '^F\w+\:\s+\K.+\.\w{1,4}$' Dogtooth\ \[2001\,\ Lanthimos\ Yorgos\].mp4.info
outputs to Dogtooth [2001, Lanthimos Yorgos].mp4 Yay!! :D
But now comes the headache... I can't get value of *File size* Original string: - File size: 4,240,762,886 bytes Expected result: - 4240762886
I only managed to get this far (matching the digits): (^.*size\:\s+\b)\K(\d.+\d) But I still miss how to get get rid of those damn *commas*...
Asked by T. Caio (129 rep)
Aug 25, 2022, 06:12 PM
Last activity: Aug 25, 2022, 11:17 PM