https://github.com/dporkka/grep
Most common grep commands
https://github.com/dporkka/grep
grep grep-command grep-search pattern-matching text-processing text-searching
Last synced: 7 months ago
JSON representation
Most common grep commands
- Host: GitHub
- URL: https://github.com/dporkka/grep
- Owner: dporkka
- Created: 2024-06-21T02:31:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-21T02:43:22.000Z (over 1 year ago)
- Last Synced: 2025-01-23T16:11:50.448Z (8 months ago)
- Topics: grep, grep-command, grep-search, pattern-matching, text-processing, text-searching
- Homepage: https://github.com/dporkka/grep
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Most common grep commands
Here are some of the most common grep commands used in the Unix/Linux command line:
## Basic Text Search:
```grep 'pattern' file```
### Case-Insensitive Search:
```grep -i 'pattern' file```
### Recursive Search:
```grep -r 'pattern' /path/to/directory```
### Search for Whole Words:
```grep -w 'pattern' file```
### ow Line Numbers:
```grep -n 'pattern' file```
### Invert Match (ow Lines That Do Not Match):
```grep -v 'pattern' file```
### Count Matching Lines:
```grep -c 'pattern' file```
### Only Matching Part of the Line:
```grep -o 'pattern' file```
### Search Multiple Patterns:
```grep -e 'pattern1' -e 'pattern2' file```
### File Names with Matches:
```grep -l 'pattern' file1 file2```
### Exclude Certain Files:
```grep --exclude=*.log 'pattern' /path/to/directory/*```
### Use Extended Regular Expressions:
```grep -E 'pattern' file```
### Suppress Errors for Non-Existent or Unreadable Files:
grep -s 'pattern' file
### Print n Lines of Context Around Matches:
Before matches:
```grep -B n 'pattern' file```
### After matches:
```grep -A n 'pattern' file```
### Both before and after matches:
```grep -C n 'pattern' file```
### Only File Names (No Duplicate Names):
```grep -L 'pattern' file1 file2```