What does this notation mean in bash?

117 Views Asked by At

I am pretty sure this will be a duplicate, because I have seen it sometimes at other places, but I do not remember where and I also (obviously) do not know how it is called.

In an other SO post, there is this piece of code (bash):

obj(){
    . <(sed "s/obj/$1/g" obj.class)
}

What does . < do ? If it has a name, what is it ?

2

There are 2 best solutions below

0
On BEST ANSWER

Source . [Docs]

Read and execute commands from the filename argument in the current shell context.

source is a synonym for dot/period . in bash, but not in POSIX sh, so for maximum compatibility use the period.


Process Substitution < () [Docs]

Process substitution allows a process’s input or output to be referred to using a filename.

0
On

Type this into your terminal:

help .

The function obj takes one argument. It executes sed and replaces all occurrences of obj in the file obj.class with the argument. The result is used as Bash code and gets evaluated by the running Bash instance.