You can capture a Screenshot of your entire screen or just a selected portion of it. The screenshot is automatically saved to your desktop.
How to take a screenshot of your entire screen
Press Shift+Command (⌘)+3.
The screenshot will be saved as a .png file on your desktop
How to take a screenshot of a selected portion of your screen
Press Shift+Command (⌘)+4. The pointer changes to a crosshair.
Move the crosshair to where you want to start the screenshot, then click and drag to select an area.
Note: While dragging the Crosshair, you can hold Shift, Option, or Space bar to change the way the selection moves
When you have selected the area that you want, release your mouse or trackpad button. To cancel, press the Esc (Escape) key before you release the button.
The screenshot will be saved as a .png file on your desktop
Update (2026): This guide has been updated with modern Linux CLI tools, performance optimizations, and common terminal patterns for searching multiple strings seamlessly.
Searching for multiple strings inside text files or terminal streams is an absolute staple of system administration, DevOps, and backend software engineering. While traditional Linux systems offer classic tools like grep, modern environments also benefit from blazing-fast alternatives like ripgrep (rg).
In this practical guide, we will break down the most effective ways to look for multiple search terms simultaneously.
1. Using grep with the OR Operator (Traditional Way)
The classic way to search for multiple strings using standard grep requires escaping the pipe | operator. This acts as a logical OR.
Bash
# General syntax
grep 'string1\|string2\|string3' filename.txt
# Example: Searching a log file for errors or warnings
grep 'ERROR\|WARNING\|CRITICAL' server.log
2. Using Extended Grep (grep -E or egrep)
To avoid messy backslash escapes, you can switch to Extended Regular Expressions by appending the -E flag (or using egrep). This makes your syntax remarkably cleaner.
Bash
# Using grep -E
grep -E 'string1|string2|string3' filename.txt
# Example: Searching for different modern framework instances
grep -E 'react|vue|angular' package.json
3. Using Multiple -e Flags
If you prefer explicit declaration or want to cleanly build your search strings dynamically using terminal scripts, you can pass multiple individual -e patterns.
Bash
# Using explicit flag pairs
grep -e 'string1' -e 'string2' filename.txt
4. The Modern Standard: Using ripgrep (rg)
If you work on modern microservices or large codebases, standard grep can feel slow. ripgrep is a modern alternative written in Rust that respects .gitignore files out of the box and matches strings using regex syntax seamlessly.
Bash
# Simple alternation using ripgrep
rg 'string1|string2' filename.txt
Quick Commands Cheat Sheet
Tool
Command Pattern
Best Used For
grep -E
grep -E 'A|B'
Built-in compatibility across all POSIX servers
grep -e
grep -e 'A' -e 'B'
Scripting & automated parsing loops
ripgrep
rg 'A|B'
Blazing-fast searches across massive repositories
Frequently Asked Questions (FAQs)
How do I search for multiple strings across all files in a directory?
You can combine the extended regex flag -E with the recursive flag -r. For example: grep -Er 'string1|string2' /path/to/directory/
How can I make the multiple string search case-insensitive?
Simply append the -i flag to your command. This tells grep to match both uppercase and lowercase variations of your keywords: grep -Ei ‘error|warning’ server.log
How do I count the total occurrences of multiple search terms?
Add the -c flag to get a specific count of matching lines, or pipe the output to wc -l: grep -E ‘string1|string2’ filename.txt | wc -l
Can I search for lines containing ALL keywords instead of ANY (Logical AND)?
Yes, but instead of using a pipe inside a single pattern, you chain multiple grep commands together via standard Unix piping: grep ‘string1’ filename.txt | grep ‘string2’