Jump to content


 Photo

Process Substitution

22 Jul 2019

Posted by sunrat in Bruno's All Things Linux
I just read this answer on Quora which is intriguing and could be rather useful. Thanks to the author Rafal Pocztarski.

Quote

   Process Substitution (Bash Reference Manual) https://www.gnu.org/...ss-Substitution


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 <(&hellip;) 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&rsquo;t even have to know that this file is in any way unusual.

Why it&rsquo;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.

289 Views · 3 Replies ( Last reply by securitybreach )

 Photo

Windows Defender Being Renamed

20 Jul 2019

Posted by Corrine in Social Media
Windows Defender Gets a New Name: Microsoft Defender

Quote

In a statement to BleepingComputer, Microsoft has stated that they are making these changes to show that their security products have become cross-platform under the umbrella name Microsoft Defender.

     “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”

559 Views · 3 Replies ( Last reply by goretsky )

 Photo

same tune?

19 Jul 2019

Twinkle Twinkle Little Star  and   Now I know My ABC's ?

487 Views · 0 Replies


Latest Discussions

Site Navigation

Online Users

0 members, 127 visitors and 0 anonymous users

Bing, Google


Portal v1.1.0 by DevFuse | Based on IP.Board Portal by IPS