Created
July 24, 2015 22:02
-
-
Save jmdeldin/f1e115c7a1e3d8bf8c44 to your computer and use it in GitHub Desktop.
Using file descriptor 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
echo "$0 [FILE] -- print a message to STDOUT or FILE" >&2 | |
if [ -z $1 ]; then | |
exec 3>&1 # stdout | |
else | |
exec 3>"$1" # file | |
fi | |
echo hello this is dog >&3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment