0
I want to return a line of context after the string I'm searching for as per grep --help
Context control:
-B, --before-context=NUM print NUM lines of leading context
-A, --after-context=NUM print NUM lines of trailing context
-C, --context=NUM print NUM lines of output context
However,
grep -a1 string1 file.txt-
gives me context before AND after (same with b1)
grep -a 1 string1 file.txt
searches for "1" in the file "string1"
and, just to make things weirder,
grep -c1 string1 file.txt
gives me nothing at all
thank you in advance to anyone who can help :)
2Are you using capitals for your
-A1
or lower case as your question has?-a
and-A
are different flags after all, I would have thought lower case would always search for 1 in a file calledstring1
– Eric Renouf – 2015-05-09T20:30:54.867fantastic. Sometimes it's the simple things :) – Some_Guy – 2015-05-09T23:06:05.783
1I wonder why a1 works as a substitute for C 1 at all though... – Some_Guy – 2015-05-09T23:09:07.787
Maybe 'cause Windows, unlike most *nixes, is case insensitive. I thought that was only a file system thing but apparently it isn't. – terdon – 2015-05-09T23:09:58.810