AWK matching multiple occurence of digitin a column [on hold]
Clash Royale CLAN TAG#URR8PPP
up vote
-2
down vote
favorite
Need to match pattern in 12th column which is in root@pts/0 format.
ps auxwww | grep sshd: | grep -v grep | awk '$12 == "root@pts/[0-9]" print $0'
awk
put on hold as unclear what you're asking by Goro, RalfFriedl, Kiwy, jimmij, roaima Oct 4 at 15:27
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |Â
up vote
-2
down vote
favorite
Need to match pattern in 12th column which is in root@pts/0 format.
ps auxwww | grep sshd: | grep -v grep | awk '$12 == "root@pts/[0-9]" print $0'
awk
put on hold as unclear what you're asking by Goro, RalfFriedl, Kiwy, jimmij, roaima Oct 4 at 15:27
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Hi, the question completly unclear. Would you please add context. It veryhelpful if you include example and the expected output
â Goro
Oct 4 at 4:03
I'm trying to grep the ssh logged in session for root user in a servers. So wanted to check how many sessions are currently active. So in the 12 column wanted to match the any terminal terminal number (i.e) root@pts/[0-9]
â ikram
Oct 4 at 4:21
# ps auxwww | grep sshd: | grep -v grep root 10682392 0.0 0.0 1936 4244 - A 20:48:11 0:00 sshd: root@pts/1 root 9437392 0.0 0.0 1936 4244 - A 20:47:24 0:00 sshd: root@pts/0
â ikram
Oct 4 at 4:21
change the==
to~
:$12 ~ "root@...
.
â mosvy
Oct 4 at 5:35
add a comment |Â
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
Need to match pattern in 12th column which is in root@pts/0 format.
ps auxwww | grep sshd: | grep -v grep | awk '$12 == "root@pts/[0-9]" print $0'
awk
Need to match pattern in 12th column which is in root@pts/0 format.
ps auxwww | grep sshd: | grep -v grep | awk '$12 == "root@pts/[0-9]" print $0'
awk
awk
edited Oct 4 at 4:02
Goro
7,24753168
7,24753168
asked Oct 4 at 3:42
ikram
21
21
put on hold as unclear what you're asking by Goro, RalfFriedl, Kiwy, jimmij, roaima Oct 4 at 15:27
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as unclear what you're asking by Goro, RalfFriedl, Kiwy, jimmij, roaima Oct 4 at 15:27
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Hi, the question completly unclear. Would you please add context. It veryhelpful if you include example and the expected output
â Goro
Oct 4 at 4:03
I'm trying to grep the ssh logged in session for root user in a servers. So wanted to check how many sessions are currently active. So in the 12 column wanted to match the any terminal terminal number (i.e) root@pts/[0-9]
â ikram
Oct 4 at 4:21
# ps auxwww | grep sshd: | grep -v grep root 10682392 0.0 0.0 1936 4244 - A 20:48:11 0:00 sshd: root@pts/1 root 9437392 0.0 0.0 1936 4244 - A 20:47:24 0:00 sshd: root@pts/0
â ikram
Oct 4 at 4:21
change the==
to~
:$12 ~ "root@...
.
â mosvy
Oct 4 at 5:35
add a comment |Â
Hi, the question completly unclear. Would you please add context. It veryhelpful if you include example and the expected output
â Goro
Oct 4 at 4:03
I'm trying to grep the ssh logged in session for root user in a servers. So wanted to check how many sessions are currently active. So in the 12 column wanted to match the any terminal terminal number (i.e) root@pts/[0-9]
â ikram
Oct 4 at 4:21
# ps auxwww | grep sshd: | grep -v grep root 10682392 0.0 0.0 1936 4244 - A 20:48:11 0:00 sshd: root@pts/1 root 9437392 0.0 0.0 1936 4244 - A 20:47:24 0:00 sshd: root@pts/0
â ikram
Oct 4 at 4:21
change the==
to~
:$12 ~ "root@...
.
â mosvy
Oct 4 at 5:35
Hi, the question completly unclear. Would you please add context. It veryhelpful if you include example and the expected output
â Goro
Oct 4 at 4:03
Hi, the question completly unclear. Would you please add context. It veryhelpful if you include example and the expected output
â Goro
Oct 4 at 4:03
I'm trying to grep the ssh logged in session for root user in a servers. So wanted to check how many sessions are currently active. So in the 12 column wanted to match the any terminal terminal number (i.e) root@pts/[0-9]
â ikram
Oct 4 at 4:21
I'm trying to grep the ssh logged in session for root user in a servers. So wanted to check how many sessions are currently active. So in the 12 column wanted to match the any terminal terminal number (i.e) root@pts/[0-9]
â ikram
Oct 4 at 4:21
# ps auxwww | grep sshd: | grep -v grep root 10682392 0.0 0.0 1936 4244 - A 20:48:11 0:00 sshd: root@pts/1 root 9437392 0.0 0.0 1936 4244 - A 20:47:24 0:00 sshd: root@pts/0
â ikram
Oct 4 at 4:21
# ps auxwww | grep sshd: | grep -v grep root 10682392 0.0 0.0 1936 4244 - A 20:48:11 0:00 sshd: root@pts/1 root 9437392 0.0 0.0 1936 4244 - A 20:47:24 0:00 sshd: root@pts/0
â ikram
Oct 4 at 4:21
change the
==
to ~
: $12 ~ "root@...
.â mosvy
Oct 4 at 5:35
change the
==
to ~
: $12 ~ "root@...
.â mosvy
Oct 4 at 5:35
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
use below
ps auxwww | grep sshd: | grep -v grep |awk -F' ' ' $12 == "root@pts/0" print $0'
In below snap, i did it for ossa user. You can use root. Mind for spaces.
New contributor
1
welcome to U&l, please do not post text as image.
â Archemar
Oct 4 at 5:36
@Archemar : Sure, thanks..
â Vieypul
Oct 4 at 5:37
add a comment |Â
up vote
0
down vote
try
ps auxwww | awk '$11 == "sshd:"' | wc -l
where
awk '$11 == "sshd:"'
filter on 11th field being sshd- or ..
'$11 == "sshd:" && $12 ~ /pts/'
wc -l
count number of line
you might whish to use pgrep
also.
thank you . It worked. Need one more information, Some times the pts/0 varies from pts/0 to pts/100. So in this case how to match it.
â ikram
Oct 4 at 5:57
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
use below
ps auxwww | grep sshd: | grep -v grep |awk -F' ' ' $12 == "root@pts/0" print $0'
In below snap, i did it for ossa user. You can use root. Mind for spaces.
New contributor
1
welcome to U&l, please do not post text as image.
â Archemar
Oct 4 at 5:36
@Archemar : Sure, thanks..
â Vieypul
Oct 4 at 5:37
add a comment |Â
up vote
0
down vote
use below
ps auxwww | grep sshd: | grep -v grep |awk -F' ' ' $12 == "root@pts/0" print $0'
In below snap, i did it for ossa user. You can use root. Mind for spaces.
New contributor
1
welcome to U&l, please do not post text as image.
â Archemar
Oct 4 at 5:36
@Archemar : Sure, thanks..
â Vieypul
Oct 4 at 5:37
add a comment |Â
up vote
0
down vote
up vote
0
down vote
use below
ps auxwww | grep sshd: | grep -v grep |awk -F' ' ' $12 == "root@pts/0" print $0'
In below snap, i did it for ossa user. You can use root. Mind for spaces.
New contributor
use below
ps auxwww | grep sshd: | grep -v grep |awk -F' ' ' $12 == "root@pts/0" print $0'
In below snap, i did it for ossa user. You can use root. Mind for spaces.
New contributor
edited Oct 4 at 5:30
Archemar
19.2k93468
19.2k93468
New contributor
answered Oct 4 at 5:26
Vieypul
1
1
New contributor
New contributor
1
welcome to U&l, please do not post text as image.
â Archemar
Oct 4 at 5:36
@Archemar : Sure, thanks..
â Vieypul
Oct 4 at 5:37
add a comment |Â
1
welcome to U&l, please do not post text as image.
â Archemar
Oct 4 at 5:36
@Archemar : Sure, thanks..
â Vieypul
Oct 4 at 5:37
1
1
welcome to U&l, please do not post text as image.
â Archemar
Oct 4 at 5:36
welcome to U&l, please do not post text as image.
â Archemar
Oct 4 at 5:36
@Archemar : Sure, thanks..
â Vieypul
Oct 4 at 5:37
@Archemar : Sure, thanks..
â Vieypul
Oct 4 at 5:37
add a comment |Â
up vote
0
down vote
try
ps auxwww | awk '$11 == "sshd:"' | wc -l
where
awk '$11 == "sshd:"'
filter on 11th field being sshd- or ..
'$11 == "sshd:" && $12 ~ /pts/'
wc -l
count number of line
you might whish to use pgrep
also.
thank you . It worked. Need one more information, Some times the pts/0 varies from pts/0 to pts/100. So in this case how to match it.
â ikram
Oct 4 at 5:57
add a comment |Â
up vote
0
down vote
try
ps auxwww | awk '$11 == "sshd:"' | wc -l
where
awk '$11 == "sshd:"'
filter on 11th field being sshd- or ..
'$11 == "sshd:" && $12 ~ /pts/'
wc -l
count number of line
you might whish to use pgrep
also.
thank you . It worked. Need one more information, Some times the pts/0 varies from pts/0 to pts/100. So in this case how to match it.
â ikram
Oct 4 at 5:57
add a comment |Â
up vote
0
down vote
up vote
0
down vote
try
ps auxwww | awk '$11 == "sshd:"' | wc -l
where
awk '$11 == "sshd:"'
filter on 11th field being sshd- or ..
'$11 == "sshd:" && $12 ~ /pts/'
wc -l
count number of line
you might whish to use pgrep
also.
try
ps auxwww | awk '$11 == "sshd:"' | wc -l
where
awk '$11 == "sshd:"'
filter on 11th field being sshd- or ..
'$11 == "sshd:" && $12 ~ /pts/'
wc -l
count number of line
you might whish to use pgrep
also.
answered Oct 4 at 5:36
Archemar
19.2k93468
19.2k93468
thank you . It worked. Need one more information, Some times the pts/0 varies from pts/0 to pts/100. So in this case how to match it.
â ikram
Oct 4 at 5:57
add a comment |Â
thank you . It worked. Need one more information, Some times the pts/0 varies from pts/0 to pts/100. So in this case how to match it.
â ikram
Oct 4 at 5:57
thank you . It worked. Need one more information, Some times the pts/0 varies from pts/0 to pts/100. So in this case how to match it.
â ikram
Oct 4 at 5:57
thank you . It worked. Need one more information, Some times the pts/0 varies from pts/0 to pts/100. So in this case how to match it.
â ikram
Oct 4 at 5:57
add a comment |Â
Hi, the question completly unclear. Would you please add context. It veryhelpful if you include example and the expected output
â Goro
Oct 4 at 4:03
I'm trying to grep the ssh logged in session for root user in a servers. So wanted to check how many sessions are currently active. So in the 12 column wanted to match the any terminal terminal number (i.e) root@pts/[0-9]
â ikram
Oct 4 at 4:21
# ps auxwww | grep sshd: | grep -v grep root 10682392 0.0 0.0 1936 4244 - A 20:48:11 0:00 sshd: root@pts/1 root 9437392 0.0 0.0 1936 4244 - A 20:47:24 0:00 sshd: root@pts/0
â ikram
Oct 4 at 4:21
change the
==
to~
:$12 ~ "root@...
.â mosvy
Oct 4 at 5:35