So I am currently reading from this txt file:
Line 961: www-d1.proxy.aol.com - - [01/Aug/1995:00:35:32 -0400] "GET /elv/hot.gif HTTP/1.0" 200 1007
Line 965: www-d1.proxy.aol.com - - [01/Aug/1995:00:35:41 -0400] "GET /elv/PEGASUS/minpeg1.gif HTTP/1.0" 200 1055
Line 966: www-d1.proxy.aol.com - - [01/Aug/1995:00:35:46 -0400] "GET /elv/SCOUT/scout.gif HTTP/1.0" 200 1165
Line 969: www-d1.proxy.aol.com - - [01/Aug/1995:00:35:49 -0400] "GET /elv/DELTA/delta.gif HTTP/1.0" 200 2244
Line 972: www-d1.proxy.aol.com - - [01/Aug/1995:00:35:51 -0400] "GET /elv/ATLAS_CENTAUR/atlas.gif HTTP/1.0" 200 2286
Line 95219: u139.n72.queensu.ca - - [04/Aug/1995:10:40:04 -0400] "GET /elv HTTP/1.0" 302 -
And I am trying to print out only the names in the command line(basically only the ones in capital letters) WITH NO DUPLICATES. For example:
ATLAS_CENTAUR
DELTA
SCOUT
PEGASUS
My codes so far:
grep "/elv" ~/spacestation.txt | awk -F/ '{print $5}' | sort -u
Actual output:
1.0" 302
ATLAS_CENTAUR
DELTA
hot.gif HTTP
SCOUT
PEGASUS
grep -c '[A-Z]' exatext1 then this will only tell you how many lines there are in exatext1 that contain words with capital letters. To know how many words there are with capital letters, one should carry out the grep -c operation on a file that only has one word from exatext1 per line: grep -c '[A-Z]' exa_words .
By default, grep is case sensitive. This means that the uppercase and lowercase characters are treated as distinct. To ignore case when searching, invoke grep with the -i option (or --ignore-case ). Specifying “Zebra” will match “zebra”, “ZEbrA” or any other combination of upper and lower case letters for that string.
Linux is a word-mark, meaning that any form of the word is covered by the trademark registration. This includes all-caps (“LINUX®”) or the standard capitalized form (“Linux®”). Either form is acceptable to the Linux Foundation so long as it is presented in a legible font.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With