The syntax is:
some command <(other command)
You use it like this:
cat <(ls -alp)
What it does is it runs the command in parentheses and provides its output as a file (a named pipe or an already opened file descriptor with its name passed in the form of e.g. /dev/fd/20).
With the above cat <(ls -alp) example, the result will be the same as just running ls -alp without cat or as running ls -alp | cat but it works differently.
The cat command gets an additional file descriptor (by default it gets 0 for stdin, 1 for stdout and 2 for stderr) and a special file representing this file descriptor for this process in the /dev/fd directory is passed as an argument in this place where <(…) was used. The cat command could use this number directly or it can open the special file as a normal file which will just clone this file descriptor, so the command that gets that file name doesn’t even have to know that this file is in any way unusual.
Why it’s useful?
E.g. you can compare two outputs of some commands using diff but without saving it in files first. For example:
ls -lp > output1.txt
ls -alp > output2.txt
diff -u output1.txt output2.txt
this can be done as one command with no saved files:
diff -u <(ls -lp) <(ls -alp)
What arguments the diff command gets can be tested by running:
echo diff -u <(ls -lp) <(ls -alp)
The result is:
diff -u /dev/fd/63 /dev/fd/62
Note that you will not be able to read those files from outside of the diff process (unless the diff process passes those file descriptors using IPC) because every process has its own set of open file descriptors so for each process the same number under /dev/fd is a different file descriptor.
“As part of our continued $1B a year investment to deliver a world class security platform for our
customers, we are extending Windows Defender ATP capabilities beyond the Windows operating
system. As a result, we are renaming to reflect our cross-platform approach to endpoint security”
479 Views · 2 Replies ( Last reply by Corrine )
sunrat - Yesterday, 08:52 PM
Windows Defender Being Renamed
Corrine - Jul 20 2019 10:50 AM
crp - Jul 19 2019 10:12 PM
EvilGnome: A New Backdoor Implant Spies On Linux Desktop Users
securitybreach - Jul 17 2019 03:12 PM
Oracle Java™ Critical Security Updates Released
Corrine - Jul 17 2019 12:00 PM
More Adventures in Networking
raymac46 - Jul 17 2019 08:30 AM
Now Playing In VirtualBox
raymac46 - Jul 16 2019 06:33 PM
raymac46 - Jul 13 2019 09:38 AM
sunrat - Jul 12 2019 08:40 PM
Is this the next ggle product to bite the dust?
crp - Jul 11 2019 11:32 PM
The Linux Cookbook....ahhh, those were the days!
wa4chq - Jul 10 2019 05:13 PM
Microsoft Security Updates for July, 2019
Corrine - Jul 09 2019 02:01 PM
Mozilla Firefox Version 68.0 Released With Security Updates
Corrine - Jul 09 2019 12:29 PM
Adobe Flash Player Update Released
Corrine - Jul 09 2019 11:07 AM
No power after outage
DarkSerge - Jul 03 2019 07:04 AM
goretsky, Bing, Google