Blogs

How to Fix Kali Linux Black Screen?
June 6, 2025
Qualcomm to Buy Alphawave for $2.4 Billion in Bid to Strengthen Data Center Position
June 10, 2025Prep Command in Linux: All You Need To Know
Prep Command in Linux
Basic Syntax
The general syntax for grep is:
grep [OPTIONS] PATTERN [FILE…]
This command searches for the specified PATTERN in the given FILE or from standard input.
Commonly Used Options
- -i: Performs a case-insensitive search.
- -v: Inverts the match to select non-matching lines.
- -n: Displays line numbers along with matching lines.
- -r or -R: Recursively searches directories.
- -c: Counts the number of matching lines.
- -l: Lists filenames containing the match.
- -w: Matches whole words only.
- -x: Matches whole lines only.
- -E: Uses extended regular expressions.
- -F: Interprets the pattern as a list of fixed strings.
- -q: Suppresses output; useful for scripting.
Read more: Windows Dedicated Server Vs Linux Dedicated Server
Practical Examples
Basic Search: Find lines containing “error” in app.log:
grep “error” app.log
Case-Insensitive Search: Find lines containing “Warning” regardless of case:
grep -i “warning” app.log
Line Numbers: Display line numbers where “critical” appears:
grep -n “critical” app.log
Recursive Search: Search for “timeout” in all .log files within a directory:
grep -r “timeout” *.log
Count Matches: Count occurrences of “failed” in auth.log:
grep -c “failed” auth.log
Exclude Matches: Show lines that do not contain “debug“:
grep -v “debug” app.log
Contextual Lines: Display 2 lines before and after each match for “error“:
grep -B 2 -A 2 “error” app.log
Using Regular Expressions: Match lines starting with “start” or ending with “end”:
grep -E “^start|end$” file.txt
Search Compressed Files: Search within a gzipped file:
zgrep “pattern” file.txt.gz
Combining with Other Commands
grep can be combined with other commands using pipes to filter their output:
- List all processes and filter for “nginx“:
ps aux | grep “nginx“
:contentReference[oaicite:105]{index=105}
– :contentReference[oaicite:107]{index=107}:contentReference[oaicite:109]{index=109}
find . -name “*.mp3” | grep -i “JayZ” | grep -vi “remix“
:contentReference[oaicite:112]{index=112}
:contentReference[oaicite:114]{index=114}:contentReference[oaicite:116]{index=116}
If you have specific scenarios or need further assistance with `grep`, feel free to ask!
::contentReference[oaicite:117]{index=117}
One server. One user. One unstoppable experience. That’s real dedication.
Cores
RAM
Storage
Location
Monthly Price
Link
Intel Xeon E3-1240 v6 3.7GHz 4c/8t
64 GB DDR4
2 x 500 GB (SSD SATA)
Amsterdam
$79.95 /month
Buy Now
Dual Intel Xeon E5-2697 2.70 GHZ v2 (24 Cores / 48 Threads)
256 GB DDR 3
Storage: 2 x 480 GB SSD
Florida
$259.95 /month
Buy Now
Intel E5-2680 2.70 GHZ 16 Cores / 32 Threads
512 GB DDR 3
Storage: 2 x 960 GB SSD
Florida
$359.95 /month
Buy Now

Muhammad Osama
Featured Post
How To Fix cPanel Access Issues?
Table of Contents How To Fix cPanel Access Issues? 1. Verify Your Internet Connection 2. Confirm the Correct cPanel URL 3. Clear Browser Cache and Cookies […]

How to Fix Kali Linux Black Screen?
Table of Contents How to Fix Kali Linux Black Screen After Login 1. Access a Text Terminal 2. Restart the Display Manager 3. Check for Corrupted […]

Server Virtualization: The Ultimate Guide
Table of Contents Server Virtualization: The Ultimate Guide What is Server Virtualization? Why Is Server Virtualization Important? What are the Key Benefits of Server Virtualization? Increased […]
