I need to find a pattern that starts with a $ is followed by two numbers, a single character that is not a number, and anything else.
I know how to find a pattern starting in a dollar sign and followed by two numbers but I can't figure out how to check for one character that is not a number.
I also need to count how many lines have this pattern.
I have this so far:
grep -Ec '\$[0-9][0-9].....
I don't know what to do. Can someone please help? Any help would be much appreciated.
插入符号反转选择组,因此,如果[0-9]
为“匹配任何数字”,则[^0-9]
为“匹配任何非数字”。
You can possibly try this regex \\$[0-9][0-9][^0-9].*
\\$[0-9][0-9][^0-9].*
I would second @realspirituals answer, and if you need to count how many lines have this pattern, you can count how many lines grep
ouputs by piping to wc -l
. In order to both show the lines and count them in one fell swoop, pipe the output like so
grep "\$[0-9]{2}[^0-9].*" | tee >(wl -l)
where tee
will split the output between wl
and STDOUT
. {2}
will cause the prior [0-9]
to match twice.
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.