Command for create and compile log
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I need a one-line command to compile and print all of the Expendable Launch Vehicle names listed in the log.
The ELV names are all listed in capital letters under the /elv
directory.
The output should appear in the format of one name per line, with no duplicates:
ALICE
BOB
CHARLIE
I tried
grep "GET" NASA_access_log_Aug95.txt | grep "ELV" | wc -l
but, it only showed me the number of ELV not printed ELV names
The below is the example of my log file (NASA_access_log_Aug95.txt)
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:31 -0400] "GET /elv/TITAN/mars1s.jpg HTTP/1.0" 200 1156
www-a2.proxy.aol.com - - [03/Aug/1995:20:43:31 -0400] "GET /elv/DELTA/dsolids.jpg HTTP/1.0" 200 24558
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:32 -0400] "GET /elv/TITAN/mars3s.jpg HTTP/1.0" 200 1744
castor.gel.usherb.ca - - [03/Aug/1995:20:43:33 -0400] "GET /shuttle/missions/51-l/movies/ HTTP/1.0" 200 372
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:33 -0400] "GET /elv/ATLAS_CENTAUR/atc69s.jpg HTTP/1.0" 200 1659
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:35 -0400] "GET /elv/TITAN/mars2s.jpg HTTP/1.0" 200 1549
palona1.cns.hp.com - - [03/Aug/1995:20:43:36 -0400] "GET /shuttle/missions/sts-69/count69.gif HTTP/1.0" 200 46053
www-c1.proxy.aol.com - - [03/Aug/1995:20:43:38 -0400] "GET /shuttle/missions/sts-71/images/KSC-95EC-0882.gif HTTP/1.0" 200 51289
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:40 -0400] "GET /elv/ATLAS_CENTAUR/acsuns.jpg HTTP/1.0" 200 2263
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:41 -0400] "GET /elv/ATLAS_CENTAUR/goess.jpg HTTP/1.0" 200 1306
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:45 -0400] "GET /elv/DELTA/dsolidss.jpg HTTP/1.0" 200 1629
command-line grep
New contributor
강찬ì is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
I need a one-line command to compile and print all of the Expendable Launch Vehicle names listed in the log.
The ELV names are all listed in capital letters under the /elv
directory.
The output should appear in the format of one name per line, with no duplicates:
ALICE
BOB
CHARLIE
I tried
grep "GET" NASA_access_log_Aug95.txt | grep "ELV" | wc -l
but, it only showed me the number of ELV not printed ELV names
The below is the example of my log file (NASA_access_log_Aug95.txt)
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:31 -0400] "GET /elv/TITAN/mars1s.jpg HTTP/1.0" 200 1156
www-a2.proxy.aol.com - - [03/Aug/1995:20:43:31 -0400] "GET /elv/DELTA/dsolids.jpg HTTP/1.0" 200 24558
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:32 -0400] "GET /elv/TITAN/mars3s.jpg HTTP/1.0" 200 1744
castor.gel.usherb.ca - - [03/Aug/1995:20:43:33 -0400] "GET /shuttle/missions/51-l/movies/ HTTP/1.0" 200 372
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:33 -0400] "GET /elv/ATLAS_CENTAUR/atc69s.jpg HTTP/1.0" 200 1659
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:35 -0400] "GET /elv/TITAN/mars2s.jpg HTTP/1.0" 200 1549
palona1.cns.hp.com - - [03/Aug/1995:20:43:36 -0400] "GET /shuttle/missions/sts-69/count69.gif HTTP/1.0" 200 46053
www-c1.proxy.aol.com - - [03/Aug/1995:20:43:38 -0400] "GET /shuttle/missions/sts-71/images/KSC-95EC-0882.gif HTTP/1.0" 200 51289
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:40 -0400] "GET /elv/ATLAS_CENTAUR/acsuns.jpg HTTP/1.0" 200 2263
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:41 -0400] "GET /elv/ATLAS_CENTAUR/goess.jpg HTTP/1.0" 200 1306
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:45 -0400] "GET /elv/DELTA/dsolidss.jpg HTTP/1.0" 200 1629
command-line grep
New contributor
강찬ì is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I need a one-line command to compile and print all of the Expendable Launch Vehicle names listed in the log.
The ELV names are all listed in capital letters under the /elv
directory.
The output should appear in the format of one name per line, with no duplicates:
ALICE
BOB
CHARLIE
I tried
grep "GET" NASA_access_log_Aug95.txt | grep "ELV" | wc -l
but, it only showed me the number of ELV not printed ELV names
The below is the example of my log file (NASA_access_log_Aug95.txt)
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:31 -0400] "GET /elv/TITAN/mars1s.jpg HTTP/1.0" 200 1156
www-a2.proxy.aol.com - - [03/Aug/1995:20:43:31 -0400] "GET /elv/DELTA/dsolids.jpg HTTP/1.0" 200 24558
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:32 -0400] "GET /elv/TITAN/mars3s.jpg HTTP/1.0" 200 1744
castor.gel.usherb.ca - - [03/Aug/1995:20:43:33 -0400] "GET /shuttle/missions/51-l/movies/ HTTP/1.0" 200 372
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:33 -0400] "GET /elv/ATLAS_CENTAUR/atc69s.jpg HTTP/1.0" 200 1659
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:35 -0400] "GET /elv/TITAN/mars2s.jpg HTTP/1.0" 200 1549
palona1.cns.hp.com - - [03/Aug/1995:20:43:36 -0400] "GET /shuttle/missions/sts-69/count69.gif HTTP/1.0" 200 46053
www-c1.proxy.aol.com - - [03/Aug/1995:20:43:38 -0400] "GET /shuttle/missions/sts-71/images/KSC-95EC-0882.gif HTTP/1.0" 200 51289
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:40 -0400] "GET /elv/ATLAS_CENTAUR/acsuns.jpg HTTP/1.0" 200 2263
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:41 -0400] "GET /elv/ATLAS_CENTAUR/goess.jpg HTTP/1.0" 200 1306
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:45 -0400] "GET /elv/DELTA/dsolidss.jpg HTTP/1.0" 200 1629
command-line grep
New contributor
강찬ì is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I need a one-line command to compile and print all of the Expendable Launch Vehicle names listed in the log.
The ELV names are all listed in capital letters under the /elv
directory.
The output should appear in the format of one name per line, with no duplicates:
ALICE
BOB
CHARLIE
I tried
grep "GET" NASA_access_log_Aug95.txt | grep "ELV" | wc -l
but, it only showed me the number of ELV not printed ELV names
The below is the example of my log file (NASA_access_log_Aug95.txt)
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:31 -0400] "GET /elv/TITAN/mars1s.jpg HTTP/1.0" 200 1156
www-a2.proxy.aol.com - - [03/Aug/1995:20:43:31 -0400] "GET /elv/DELTA/dsolids.jpg HTTP/1.0" 200 24558
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:32 -0400] "GET /elv/TITAN/mars3s.jpg HTTP/1.0" 200 1744
castor.gel.usherb.ca - - [03/Aug/1995:20:43:33 -0400] "GET /shuttle/missions/51-l/movies/ HTTP/1.0" 200 372
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:33 -0400] "GET /elv/ATLAS_CENTAUR/atc69s.jpg HTTP/1.0" 200 1659
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:35 -0400] "GET /elv/TITAN/mars2s.jpg HTTP/1.0" 200 1549
palona1.cns.hp.com - - [03/Aug/1995:20:43:36 -0400] "GET /shuttle/missions/sts-69/count69.gif HTTP/1.0" 200 46053
www-c1.proxy.aol.com - - [03/Aug/1995:20:43:38 -0400] "GET /shuttle/missions/sts-71/images/KSC-95EC-0882.gif HTTP/1.0" 200 51289
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:40 -0400] "GET /elv/ATLAS_CENTAUR/acsuns.jpg HTTP/1.0" 200 2263
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:41 -0400] "GET /elv/ATLAS_CENTAUR/goess.jpg HTTP/1.0" 200 1306
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:45 -0400] "GET /elv/DELTA/dsolidss.jpg HTTP/1.0" 200 1629
command-line grep
command-line grep
New contributor
강찬ì is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
강찬ì is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 1 hour ago


karel
51.6k11107131
51.6k11107131
New contributor
강찬ì is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 3 hours ago
강찬ì
62
62
New contributor
강찬ì is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
강찬ì is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
강찬ì is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
1
down vote
Don't you need just:
awk -F'/' '/elv/ && !seen[$5]++ print $5' infile
for the given sample, output would be:
TITAN
DELTA
ATLAS_CENTAUR
add a comment |Â
up vote
1
down vote
You can do it like this:
grep 'elv' NASA_access_log_Aug95.txt | awk 'print $7' | sed 's/[a-z0-9./]//g' | sort -u
Given your example snippet from the log file this will output:
ATLAS_CENTAUR
DELTA
TITAN
Explanation of the piped commands in order they occur:
grep 'elv' NASA_access_log_Aug95.txt
Will output you all lines containing
elv
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:31 -0400] "GET /elv/TITAN/mars1s.jpg HTTP/1.0" 200 1156
www-a2.proxy.aol.com - - [03/Aug/1995:20:43:31 -0400] "GET /elv/DELTA/dsolids.jpg HTTP/1.0" 200 24558
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:32 -0400] "GET /elv/TITAN/mars3s.jpg HTTP/1.0" 200 1744
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:33 -0400] "GET /elv/ATLAS_CENTAUR/atc69s.jpg HTTP/1.0" 200 1659
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:35 -0400] "GET /elv/TITAN/mars2s.jpg HTTP/1.0" 200 1549
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:40 -0400] "GET /elv/ATLAS_CENTAUR/acsuns.jpg HTTP/1.0" 200 2263
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:41 -0400] "GET /elv/ATLAS_CENTAUR/goess.jpg HTTP/1.0" 200 1306
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:45 -0400] "GET /elv/DELTA/dsolidss.jpg HTTP/1.0" 200 1629awk 'print $7'
Will give you the 7th column information (the one you want). Remember That this counts colums divided by spaces.
/elv/TITAN/mars1s.jpg
/elv/DELTA/dsolids.jpg
/elv/TITAN/mars3s.jpg
/elv/ATLAS_CENTAUR/atc69s.jpg
/elv/TITAN/mars2s.jpg
/elv/ATLAS_CENTAUR/acsuns.jpg
/elv/ATLAS_CENTAUR/goess.jpg
/elv/DELTA/dsolidss.jpgsed 's/[a-z0-9./]//g'
Will filter out all unwanted characters (i.e. lower case
a-z
, numbers0-9
,.
and/
)TITAN
DELTA
TITAN
ATLAS_CENTAUR
TITAN
ATLAS_CENTAUR
ATLAS_CENTAUR
DELTAsort -u
Will prevent duplicates from appearing and sorts them alphabetically.
ATLAS_CENTAUR
DELTA
TITAN
add a comment |Â
up vote
1
down vote
With Perl, regex matching the /
-delimited elements after elv
and pushing them into a hash:
$ perl -lne '$h$1++ if m:/elv/(.*?)/: } sort -u
Given your example snippet from the log file this will output:
ATLAS_CENTAUR
DELTA
TITAN
Explanation of the piped commands in order they occur:
grep 'elv' NASA_access_log_Aug95.txt
Will output you all lines containing
elv
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:31 -0400] "GET /elv/TITAN/mars1s.jpg HTTP/1.0" 200 1156
www-a2.proxy.aol.com - - [03/Aug/1995:20:43:31 -0400] "GET /elv/DELTA/dsolids.jpg HTTP/1.0" 200 24558
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:32 -0400] "GET /elv/TITAN/mars3s.jpg HTTP/1.0" 200 1744
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:33 -0400] "GET /elv/ATLAS_CENTAUR/atc69s.jpg HTTP/1.0" 200 1659
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:35 -0400] "GET /elv/TITAN/mars2s.jpg HTTP/1.0" 200 1549
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:40 -0400] "GET /elv/ATLAS_CENTAUR/acsuns.jpg HTTP/1.0" 200 2263
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:41 -0400] "GET /elv/ATLAS_CENTAUR/goess.jpg HTTP/1.0" 200 1306
cc-rd6-mg1-dip4-9.massey.ac.nz - - [03/Aug/1995:20:43:45 -0400] "GET /elv/DELTA/dsolidss.jpg HTTP/1.0" 200 1629awk 'print $7'
Will give you the 7th column information (the one you want). Remember That this counts colums divided by spaces.
/elv/TITAN/mars1s.jpg
/elv/DELTA/dsolids.jpg
/elv/TITAN/mars3s.jpg
/elv/ATLAS_CENTAUR/atc69s.jpg
/elv/TITAN/mars2s.jpg
/elv/ATLAS_CENTAUR/acsuns.jpg
/elv/ATLAS_CENTAUR/goess.jpg
/elv/DELTA/dsolidss.jpgsed 's/[a-z0-9./]//g'
Will filter out all unwanted characters (i.e. lower case
a-z
, numbers0-9
,.
and/
)TITAN
DELTA
TITAN
ATLAS_CENTAUR
TITAN
ATLAS_CENTAUR
ATLAS_CENTAUR
DELTAsort -u
Will prevent duplicates from appearing and sorts them alphabetically.
ATLAS_CENTAUR
DELTA
TITAN
up vote
1
down vote
With Perl, regex matching the /
-delimited elements after elv
and pushing them into a hash:
$ perl -lne '$h$1++ if m:/elv/(.*?)/: Â
up vote
1
down vote
up vote
1
down vote
With Perl, regex matching the /
-delimited elements after elv
and pushing them into a hash:
$ perl -lne '$h$1++ if m:/elv/(.*?)/: improve this answer
With Perl, regex matching the /
-delimited elements after elv
and pushing them into a hash:
$ perl -lne '$h$1++ if m:/elv/(.*?)/: { for $k (sort keys %h) print $k' NASA_access_log_Aug95.txt
ATLAS_CENTAUR
DELTA
TITAN
answered 19 mins ago
steeldriver
63.4k1199167
63.4k1199167
add a comment |Â
add a comment |Â
강찬ì is a new contributor. Be nice, and check out our Code of Conduct.
강찬ì is a new contributor. Be nice, and check out our Code of Conduct.
강찬ì is a new contributor. Be nice, and check out our Code of Conduct.
강찬ì is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1079432%2fcommand-for-create-and-compile-log%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password