I have the following grep
grep "/abc/[A-Z]" file1.txt | cut -d/ f3 | sort -u
The grep worked perfectly returning the results,
ALPHA
abc
BRAVO
CHARLIE
However, why is the abc
in the output too? I have made the regex to only take capitalize words after the delimiter backslash. Is this an intended output and how should I remove the abc
from the output?
grep -o
prints the matching part only. Which would be e.g./abc/A
here, not/abc/ALPHA
.abc
, then you'll need to add sample text to your question so that we have an idea of what you are working with.cut f3
reads a file calledf3
. You probably usedcut -f3
. Also, if you want the whole name to be uppercase, you need a repeat on the character range, and a terminator, like[A-Z]+$
: your pattern only examines the first character of the field.