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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -