- 1 year ago
gnu grep --include file extension case sensitivity
Comment
1 / 1
By default, GNU grep
is case-sensitive when performing searches. However, you can make it case-insensitive by using the -i
option. To search only specific file extensions and make the search case-sensitive or case-insensitive, you can use the --include
and -i
options together. Here's the general syntax:
cssgrep [OPTIONS] PATTERN --include=PATTERN [FILE...]
Where:
[OPTIONS]
represents any additional options you want to pass togrep
.PATTERN
is the text you want to search for.--include=PATTERN
specifies the file pattern to include in the search (e.g.,*.txt
).[FILE...]
represents the files or directories you want to search in.
If you want to perform a case-sensitive search on specific file extensions, simply omit the -i
option. For example:
perlgrep "pattern" --include="*.txt" file1.txt file2.txt
If you want to perform a case-insensitive search on specific file extensions, use the -i
option:
perlgrep -i "pattern" --include="*.txt" file1.txt file2.txt
With the -i
option, grep
will ignore case while searching for the specified pattern in the files with the .txt
extension.