How to find the total number of processes in Unix/Linux shell script

Cidricc

I’m trying to find the total lines of running processes excepting the commands I’m using to create the listing.

Then to parse out the userID and the PID into a new list.

All within the same shell.

So far I have:

ps -ef | grep filename | wc -l
twentybeersreserved

so here is a command for processes list:

ps -ef | tr -s ' ' | awk '{ if ($8=="/usr/sbin/apache2") print $1, $2 }'

We print only first two columns of each line (userId, PID) where column8 is equal to /usr/sbin/apache2 (process name)

and here is a command for processes count:

ps -ef | tr -s ' ' | awk '{ if ($8=="/usr/sbin/apache2") print $1, $2 }' | wc -l

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Shell script to find and count total number of characters in all the files

From Java

How can I find out the total physical memory (RAM) of my linux box suitable to be parsed by a shell script?

From Dev

How to count the total number of the opened files by the users and processes on my machine

From Dev

How to count the total number of the opened files by the users and processes on my machine

From Dev

why is the total number of processes 2

From Dev

How to find Kmeans total number of iterations?

From Dev

How to find total number of files selected in QtDialog?

From Dev

How to get (from terminal) total number of threads (per process and total for all processes)

From Dev

How to find script directory in an included shell script

From Dev

How to find script directory in an included shell script

From Dev

Finding running processes in shell script

From Dev

how to find number of processes running particular command in python

From Dev

how to find number of processes running particular command in python

From Dev

How to find the total number of occurrences of text and files with find command

From Dev

Will killing Python script that called shell processes also kill the shell processes?

From Dev

How to compare to floating point number in a shell script

From Dev

how to count the number of lines in a variable in a shell script

From Dev

how to convert number to time format in shell script?

From Dev

How to compare to floating point number in a shell script

From Dev

How to control the number of background job in shell script

From Dev

Bash Script to find zombie processes?

From Dev

How to find this pattern with grep in a shell script?

From Dev

How to write a shell script to find PID and Kill

From Dev

How to get find -exec to call a shell script?

From Dev

How to find and replace the text in shell script

From Dev

How to use find to fill in variable in Shell script

From Dev

How to find match and corresponding value in Shell script

From Dev

Unix shell script to find string in a file then append by adding characters or number

From Dev

How to find out total number of bytes stored in ByteBuffer?

Related Related

  1. 1

    Shell script to find and count total number of characters in all the files

  2. 2

    How can I find out the total physical memory (RAM) of my linux box suitable to be parsed by a shell script?

  3. 3

    How to count the total number of the opened files by the users and processes on my machine

  4. 4

    How to count the total number of the opened files by the users and processes on my machine

  5. 5

    why is the total number of processes 2

  6. 6

    How to find Kmeans total number of iterations?

  7. 7

    How to find total number of files selected in QtDialog?

  8. 8

    How to get (from terminal) total number of threads (per process and total for all processes)

  9. 9

    How to find script directory in an included shell script

  10. 10

    How to find script directory in an included shell script

  11. 11

    Finding running processes in shell script

  12. 12

    how to find number of processes running particular command in python

  13. 13

    how to find number of processes running particular command in python

  14. 14

    How to find the total number of occurrences of text and files with find command

  15. 15

    Will killing Python script that called shell processes also kill the shell processes?

  16. 16

    How to compare to floating point number in a shell script

  17. 17

    how to count the number of lines in a variable in a shell script

  18. 18

    how to convert number to time format in shell script?

  19. 19

    How to compare to floating point number in a shell script

  20. 20

    How to control the number of background job in shell script

  21. 21

    Bash Script to find zombie processes?

  22. 22

    How to find this pattern with grep in a shell script?

  23. 23

    How to write a shell script to find PID and Kill

  24. 24

    How to get find -exec to call a shell script?

  25. 25

    How to find and replace the text in shell script

  26. 26

    How to use find to fill in variable in Shell script

  27. 27

    How to find match and corresponding value in Shell script

  28. 28

    Unix shell script to find string in a file then append by adding characters or number

  29. 29

    How to find out total number of bytes stored in ByteBuffer?

HotTag

Archive