bash - How to make readable alias of a file descriptor -
i know how make alias of file descriptor
exec 3>&1 1> /dev/null echo "hello world" >&3
but not readable. there way make readable (means instead of >&3 can write log or info or debug) ?
you can use parameters store file descriptor use.
exec 3>&1 1>/dev/null log=3 echo "hello world" >&$log
you cannot store >&
part in parameter, because shell syntax, not data. can, however, write function output argument(s) specific file descriptor.
log () { echo "$@" >&3 } log "hello world"
Comments
Post a Comment