简体   繁体   中英

greping a specific regex

I am trying to print out every string that starts with three 0's, ends with three 1's and has zero or more 0's in between.

I was given a file with one large string, with XXX separating the different string I needed to check.

I used sed to break up the string into separate lines wherever there is XXX, but I am trying pipe it into a grep with a specific regular expressions to display only the patterns that I want.

sed "blah blah" | grep 000*111

This displays strings like "1", "111", "000". What wold the regex be to get this specific pattern? Or can I not use grep with a regex like this?

Try this :

sed "blah blah" | fgrep '000*111'

$ whatis fgrep

fgrep (1) - print lines matching a pattern

aka literal, not regex

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM