grep -o 'pattern' file.txt

Category: Text Processing

grep -o 'pattern' file.txt

Print only the matched portion of each line

Prints only the part of each line that matched the pattern, not the whole line.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.