0

I create the following text and when you want to search for the pattern "10?", it doesn't recognize anything, let's see:

ubuntu@ip-172-31-30-142:~$ cat > demo1.txt
10 1 101 10
1
10
101
1010111
10
1 10
1 1 1 1 10
1 1
1 0
0 10
1
ubuntu@ip-172-31-30-142:~$ cat demo1.txt
10 1 101 10
1
10
101
1010111
10
1 10
1 1 1 1 10
1 1
1 0
0 10
1
ubuntu@ip-172-31-30-142:~$ grep "10?" demo1.txt
ubuntu@ip-172-31-30-142:~$

Why doesn't it recognize the pattern set in the regular expression?

enter image description here

1 Answers1

3

The ? special character is part of extended regular expressions. grep -E "10?" demo1.txt should return the result you're looking for.

David Yockey
  • 1,834