Start the long-running report.sh from an interactive shell and immediately regain the prompt.
Which input is appropriate?
Appending & starts the command as a background shell job and returns the prompt.
Detailed explanation
./report.sh &Correct. ./report.sh & starts the command in the background.
Correct. ./report.sh & starts the command in the background.
./report.sh |Incorrect. A pipe requires a command on the right side.
Incorrect. A pipe requires a command on the right side.
./report.sh >Incorrect. A redirection operator requires a destination.
Incorrect. A redirection operator requires a destination.
./report.sh &&Incorrect. && waits for the first command to succeed before running another.
Incorrect. && waits for the first command to succeed before running another.
Try it yourself
An example you can run in a temporary verification environment.
sleep 0.1 & waitExpected result
短命background processを待って正常終了Key points
- &
- Background job
- Shell prompt
Notes
- Environment: Bash 5.x
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.