How to make readable alias of a file descriptor

Patrick

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) ?

chepner

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Make a file more readable

From Dev

How to get Readable file descriptor from a byte-stream source from compressed files (gz)

From Dev

Make file readable for system but not users

From Dev

How to reserve a file descriptor?

From Dev

Yii - how to make url as readable?

From Dev

hosts file and unclear behavior. How to make real alias?

From Dev

Make file readable by CGI but not web browser

From Dev

Make file readable by CGI but not web browser

From Dev

Quickly make a file readable and its path executable?

From Dev

How to make a alias to rsync?

From Dev

How to make a wget 'alias'?

From Dev

How to make alias interpretive?

From Dev

How to make alias for atom?

From Dev

How to make an alias for a command?

From Dev

How to make URL alias

From Dev

How to know if a file descriptor is opened?

From Dev

how to return file descriptor in c

From Dev

How to verify if a file is readable by humans?

From Dev

How to save content of the QSettings file on Android to make it readable after updating my app from Play Store?

From Dev

How does one make an already opened file readable (e.g. sys.stdout)?

From Dev

How do I make any newly created file in a specific directory executable, readable and writable by default by all users

From Dev

Etymology of "descriptor" in "file descriptor"

From Dev

How to make numbers 'human readable' in MySQL

From Dev

how to make this code more functional and readable?

From Dev

How can I make text in meld readable?

From Dev

How to optimize and make the code more readable

From Dev

How can I make text in meld readable?

From Dev

How to make a 2002 ISO image readable?

From Dev

How to make HTML code more readable?

Related Related

HotTag

Archive