I am using grep -A command to get a specific pattern. It gives -- at the end of every block, how I can remove these dashes?
2 Answers
AFAIK it's not mentioned in the man page, but in the Context Line Control section of info grep you will find the option
‘--no-group-separator’ When ‘-A’, ‘-B’ or ‘-C’ are in use, do not print a separator between groups of lines. You have at least three alternatives:
With
-voption (works on any version of grep):... | grep -A1 "pattern" | grep -v -- "^--$"Also,
| sed '/^--$/d'.With undocumented
--group-separator... | grep -A1 "pattern" --group-separator ""With
--no-group-separator(as mentioned steeldriver).... | grep -A1 "pattern" --no-group-separator