grep multiple entries in openvpn.log
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
i need to determine which clients tried to connect to openvpn
$ grep -e 'client[1-20]' openvpn.log | sed 's/^.*client/client/'
gives me
client16
client16
client12_pool_defined = DISABLED
client12'/var/run/openvpn.pid'
client13
client15
client16
client16
any idea how to remove duplicate entries just leaving client12, client13 and so on?
bash sed grep openvpn
add a comment |Â
up vote
-1
down vote
favorite
i need to determine which clients tried to connect to openvpn
$ grep -e 'client[1-20]' openvpn.log | sed 's/^.*client/client/'
gives me
client16
client16
client12_pool_defined = DISABLED
client12'/var/run/openvpn.pid'
client13
client15
client16
client16
any idea how to remove duplicate entries just leaving client12, client13 and so on?
bash sed grep openvpn
Does adding| uniq
give you the expected output or is further sorting needed?
â Mikael Kjær
Apr 19 at 4:19
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
i need to determine which clients tried to connect to openvpn
$ grep -e 'client[1-20]' openvpn.log | sed 's/^.*client/client/'
gives me
client16
client16
client12_pool_defined = DISABLED
client12'/var/run/openvpn.pid'
client13
client15
client16
client16
any idea how to remove duplicate entries just leaving client12, client13 and so on?
bash sed grep openvpn
i need to determine which clients tried to connect to openvpn
$ grep -e 'client[1-20]' openvpn.log | sed 's/^.*client/client/'
gives me
client16
client16
client12_pool_defined = DISABLED
client12'/var/run/openvpn.pid'
client13
client15
client16
client16
any idea how to remove duplicate entries just leaving client12, client13 and so on?
bash sed grep openvpn
asked Apr 19 at 4:10
toxikas
6
6
Does adding| uniq
give you the expected output or is further sorting needed?
â Mikael Kjær
Apr 19 at 4:19
add a comment |Â
Does adding| uniq
give you the expected output or is further sorting needed?
â Mikael Kjær
Apr 19 at 4:19
Does adding
| uniq
give you the expected output or is further sorting needed?â Mikael Kjær
Apr 19 at 4:19
Does adding
| uniq
give you the expected output or is further sorting needed?â Mikael Kjær
Apr 19 at 4:19
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
First: grep 'client[1-20]'
does not look for client
followed by numbers between 1 and 20. It looks for client
followed by any character out of 0
, 1
and 2
. Using grep
for a range of numbers is cumbersome and dealt with multiple times in this site. See, for example, Grep for range of numbers, Looking to grep or egrep year ranges from 1965-1996, etc.
If you want just unique entries, use sort -u
or sort | uniq
.
Combined, something like (assuming zero-padded numbers):
grep -Eo 'client([01][1-9]|20)' | sort -u
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
First: grep 'client[1-20]'
does not look for client
followed by numbers between 1 and 20. It looks for client
followed by any character out of 0
, 1
and 2
. Using grep
for a range of numbers is cumbersome and dealt with multiple times in this site. See, for example, Grep for range of numbers, Looking to grep or egrep year ranges from 1965-1996, etc.
If you want just unique entries, use sort -u
or sort | uniq
.
Combined, something like (assuming zero-padded numbers):
grep -Eo 'client([01][1-9]|20)' | sort -u
add a comment |Â
up vote
1
down vote
First: grep 'client[1-20]'
does not look for client
followed by numbers between 1 and 20. It looks for client
followed by any character out of 0
, 1
and 2
. Using grep
for a range of numbers is cumbersome and dealt with multiple times in this site. See, for example, Grep for range of numbers, Looking to grep or egrep year ranges from 1965-1996, etc.
If you want just unique entries, use sort -u
or sort | uniq
.
Combined, something like (assuming zero-padded numbers):
grep -Eo 'client([01][1-9]|20)' | sort -u
add a comment |Â
up vote
1
down vote
up vote
1
down vote
First: grep 'client[1-20]'
does not look for client
followed by numbers between 1 and 20. It looks for client
followed by any character out of 0
, 1
and 2
. Using grep
for a range of numbers is cumbersome and dealt with multiple times in this site. See, for example, Grep for range of numbers, Looking to grep or egrep year ranges from 1965-1996, etc.
If you want just unique entries, use sort -u
or sort | uniq
.
Combined, something like (assuming zero-padded numbers):
grep -Eo 'client([01][1-9]|20)' | sort -u
First: grep 'client[1-20]'
does not look for client
followed by numbers between 1 and 20. It looks for client
followed by any character out of 0
, 1
and 2
. Using grep
for a range of numbers is cumbersome and dealt with multiple times in this site. See, for example, Grep for range of numbers, Looking to grep or egrep year ranges from 1965-1996, etc.
If you want just unique entries, use sort -u
or sort | uniq
.
Combined, something like (assuming zero-padded numbers):
grep -Eo 'client([01][1-9]|20)' | sort -u
answered Apr 19 at 4:30
Olorin
1,15711
1,15711
add a comment |Â
add a comment |Â
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%2funix.stackexchange.com%2fquestions%2f438637%2fgrep-multiple-entries-in-openvpn-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
Does adding
| uniq
give you the expected output or is further sorting needed?â Mikael Kjær
Apr 19 at 4:19