Multiple choice technology operating systems

Which of the following would return the process ID of the sleep command

  1. a. sleep 1 & echo $
  2. b. sleep 1 & echo $#
  3. c. sleep 1 & echo $$
  4. d. sleep 1 & echo $!
  5. e. sleep 1 && echo $0
Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In shell, $! gives the process ID of the last background command. When 'sleep 1 &' is executed, sleep runs in background. $$ gives current shell PID, $# gives argument count, and $0 is the script name.