Print only words with Capital Letters (Linux)
Could you please try following, written and tested with shown samples only in GNU awk
.
your_command | awk '
match($0,/"GET \/[a-zA-Z]+\/[^/]*/){
val=substr($0,RSTART,RLENGTH)
sub(/.*\//,"",val)
if(val!~/[a-z]/){ print val }
val=""
}'
Single command line:
grep -E '/elv/[A-Z]+' infile | sed -E 's:.*/elv/([A-Z_]+).*:\1:'
if sort
is needed/allowed,
grep -E '/elv/[A-Z]+' infile | sed -E 's:.*/elv/([A-Z_]+).*:\1:' | sort -u
You need to put regex pattern in your awk script to compare $5:
Solution:
grep "/elv" ~/spacestation.txt | awk -F/ '$5 ~ /^[A-Z_]+/ {print $5}' | sort -u
- '~' is for compare $5 with regex pattern matching
- '^' is first character of word
- '[A-Z_]' will look for all caps-lock characters including with _
- '+' is for to continue with matching [A-Z_] if he finds one or more character like this