Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the name for `<(...)` 'operator' in bash?

I'm familiar with creating 'temporary files' for command input in bash, e.g.

cat file_1 <(echo hello) file_2

I want to read more about the subject, but I don't know the name of the <( ) operator. I suspect it's a kind of IO redirect.

Is there a name for this notation/operator?

like image 280
Armand Avatar asked Jul 29 '15 14:07

Armand


People also ask

What are operators in bash?

Bash has a large set of logical operators that can be used in conditional expressions. The most basic form of the if control structure tests for a condition and then executes a list of program statements if the condition is true. There are three types of operators: file, numeric, and non-numeric operators.

What does [- Z $1 mean in bash?

$1 means an input argument and -z means non-defined or empty. You're testing whether an input argument to the script was defined when running the script. Follow this answer to receive notifications.

What does [[ ]] mean in bash?

The [[ ... ]] part allows to test a condition using operators. Think of it as an if statement. In your example, you're using the -s operator, which tests that the referenced file is not empty. Copy link CC BY-SA 3.0.

What is := in shell script?

Using and Setting Default Values There is another syntax, ":=", which sets the variable to the default if it is undefined: echo "Your name is : ${myname:=John Doe}" This technique means that any subsequent access to the $myname variable will always get a value, either entered by the user, or "John Doe" otherwise.


1 Answers

This is called process substitution:

Process substitution is a form of redirection where the input or output of a process (some sequence of commands) appear as a temporary file.

Also from Bash Reference Manual → 3.5.6 Process Substitution:

Process substitution allows a process’s input or output to be referred to using a filename. It takes the form of

<(list)

or

>(list)

The process list is run asynchronously, and its input or output appears as a filename. This filename is passed as an argument to the current command as the result of the expansion. If the >(list) form is used, writing to the file will provide input for list. If the <(list) form is used, the file passed as an argument should be read to obtain the output of list. Note that no space may appear between the < or > and the left parenthesis, otherwise the construct would be interpreted as a redirection. Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files.

When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion.

like image 169
fedorqui 'SO stop harming' Avatar answered Sep 27 '22 21:09

fedorqui 'SO stop harming'