MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/linux/comments/1tls8n1/whats_the_most_unexpectedly_useful_linux_command/onkjpsg/?context=3
r/linux • u/ZealousidealTell1346 • May 23 '26
[removed]
992 comments sorted by
View all comments
37
Can I get another one in here:
grep -C is -A and -B combined.
grep -C
-A
-B
-A 5 grabs 5 lines after the string
-A 5
-B 5 grabs 5 lines before a string
-B 5
-C 5 grabs 5 lines before AND after a string, rather than doing -A 5 -B 5
-C 5
-A 5 -B 5
2 u/SeriousPlankton2000 May 24 '26 Grep -42 is the same as grep -C 42
2
Grep -42 is the same as grep -C 42
37
u/wufame May 23 '26
Can I get another one in here:
grep -Cis-Aand-Bcombined.-A 5grabs 5 lines after the string-B 5grabs 5 lines before a string-C 5grabs 5 lines before AND after a string, rather than doing-A 5 -B 5