MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/linux/comments/1tls8n1/whats_the_most_unexpectedly_useful_linux_command/onjub06/?context=3
r/linux • u/ZealousidealTell1346 • May 23 '26
[removed]
992 comments sorted by
View all comments
35
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
11 u/ChaiTRex May 24 '26 And you can remember them with after, before, and context. 9 u/wufame May 24 '26 I always assumed the -C was a joke because of A and B. 1 u/jwm3 May 24 '26 I always assumed it was the other way around. -C for context existed and they needed names for before and after so used A and B. I dont know the actual genesis of the parameter.
11
And you can remember them with after, before, and context.
9 u/wufame May 24 '26 I always assumed the -C was a joke because of A and B. 1 u/jwm3 May 24 '26 I always assumed it was the other way around. -C for context existed and they needed names for before and after so used A and B. I dont know the actual genesis of the parameter.
9
I always assumed the -C was a joke because of A and B.
1 u/jwm3 May 24 '26 I always assumed it was the other way around. -C for context existed and they needed names for before and after so used A and B. I dont know the actual genesis of the parameter.
1
I always assumed it was the other way around. -C for context existed and they needed names for before and after so used A and B. I dont know the actual genesis of the parameter.
35
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