sh command: exec 2>&1

Technically speaking it duplicates, or copies, stderr onto stdout. Usually you don’t need the exec to perform this. A more typical use of exec with file descriptors is to indicate that you want to assign a file to an unused file descriptor, e.g. exec 35< my_input BTW Don’t forget that the sequence of declaration when …

Read more

Get the name of the caller script in bash script

Based on @user3100381’s answer, here’s a much simpler command to get the same thing which I believe should be fairly portable: PARENT_COMMAND=$(ps -o comm= $PPID) Replace comm= with args= to get the full command line (command + arguments). The = alone is used to suppress the headers. See: