I know how to make alias of a file descriptor
exec 3>&1 1> /dev/null
echo "hello world" >&3
but this is not readable. Is there any way to make it readable (means instead of >&3 can I write LOG or INFO or DEBUG) ?
You can simply use parameters to store the file descriptor to use.
exec 3>&1 1>/dev/null
LOG=3
echo "hello world" >&$LOG
You cannot store the >&
part in a parameter, because that is shell syntax, not data. You can, however, write a function which will output its argument(s) to a specific file descriptor.
LOG () {
echo "$@" >&3
}
LOG "hello world"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments