189k views
3 votes
Unix.

List the commands to do the following:
3. Use pipes, along with ps and grep to:
a) Display all of the bash processes running on the machine (note:
in many cases, this will
display as ‘-bash’). Display ONLY the bash processes - filter out any grep processes.
b) Modify the last job by adding an appropriate command to display the number of bash
processes

1 Answer

6 votes

Final answer:

To display only the bash processes running on the machine and filter out any grep processes using pipes, you can use the 'ps' command with 'grep'. To modify the last job and display the number of bash processes, use 'wc -l'.

Step-by-step explanation:

To display only the bash processes running on the machine and filter out any grep processes, you can use the pipe operator '|' to connect the 'ps' command with the 'grep' command. Here's the command:

ps aux | grep bash | grep -v grep

This command filters the 'ps' output to only include lines containing 'bash' and then excludes any lines containing 'grep'.

If you want to modify the last job and display the number of bash processes, you can append the 'wc -l' command at the end. Here's the modified command:

ps aux | grep bash | grep -v grep | wc -l

This command uses 'wc -l' to count the number of lines in the output, which represents the number of bash processes.

User Bentzy
by
7.9k points