Need explanations for Linux bash builtin exec command behavior
问题 From Bash Reference Manual I get the following about exec bash builtin command: If command is supplied, it replaces the shell without creating a new process. Now I have the following bash script: #!/bin/bash exec ls; echo 123; exit 0 This executed, I got this: cleanup.sh ex1.bash file.bash file.bash~ output.log (files from the current directory) Now, if I have this script: #!/bin/bash exec ls | cat echo 123 exit 0 I get the following output: cleanup.sh ex1.bash file.bash file.bash~ output.log