AWK matching multiple occurence of digitin a column [on hold]

The name of the pictureThe name of the pictureThe name of the pictureClash 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'









share|improve this 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















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'









share|improve this 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













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'









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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











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.



enter image description here






share|improve this answer










New contributor




Vieypul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • 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

















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.






share|improve this answer




















  • 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

















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.



enter image description here






share|improve this answer










New contributor




Vieypul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • 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














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.



enter image description here






share|improve this answer










New contributor




Vieypul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • 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












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.



enter image description here






share|improve this answer










New contributor




Vieypul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









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.



enter image description here







share|improve this answer










New contributor




Vieypul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer








edited Oct 4 at 5:30









Archemar

19.2k93468




19.2k93468






New contributor




Vieypul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered Oct 4 at 5:26









Vieypul

1




1




New contributor




Vieypul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Vieypul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Vieypul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 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




    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












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.






share|improve this answer




















  • 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














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.






share|improve this answer




















  • 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












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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










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
















  • 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


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay