You can do:
grep -i error report.txt
There is really no need to more
the file and then pipe it to grep
. You can pass the filename as an argument to grep
.
To make the search case insensitive, you use the -i
option of grep
.
And there is really no need to go for -E
option as the pattern you are using error
is not an extended regex.
The cause of the error you are seeing is that your pattern (?i)(error)
is interpreted by the shell and since the shell did not except to see (
in this context it throws an error, something similar to when you do ls (*)
.
To fix this you quote your pattern. But that will not solve your problem of finding error
in the file because the pattern (?i)(error)
looks for the string 'ierror'
!!