Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 16420

How to get matched pattern in ugrep

$
0
0

I have created a ugrep command and file

ugrep -Hn -e 'Error:XX234 - \S+\.txt : cannot find user' -e 'Error:XX235 - \S+\.pdf : cannot find data' --format='%f:%n:%o%~'  *

File content

1_Error0: rwPqdEPE.txt - YjTccJITSpALx1B8cORNErrorXX235 - xyz.pdf : cannot find dataError:XX235 - xyz.pdf : cannot find dataError:XX234 - abc.txt : cannot find user

Output

enter image description here

I am expecting below in the output:

  1. display which pattern was matched with error

Above is just a sample ugrep command. my actual command will be quite big like below

ugrep -Hn -e pattern1 -e pattern2 -e patternN --format='%f:%n:%o%~' *

Expected output

issue.txt:12:Error:XX235 - xyz.pdf : cannot find data:<pattern2>issue.txt:13:Error:XX234 - abc.txt : cannot find user:<patternN>

Viewing all articles
Browse latest Browse all 16420

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>