Difference between revisions of "Read output of shell command from a file"
From Notes_Wiki
(Created page with "<yambe:breadcrumb>Shell_operators|Shell operators</yambe:breadcrumb> =Read output of shell command from a file= It is always possible to use normal shell redirect such as: <p...") |
m |
||
Line 1: | Line 1: | ||
[[Main_Page|Home]] > [[Shell scripting]] > [[Shell operators]] > [[Read output of shell command from a file]] | |||
It is always possible to use normal shell redirect such as: | It is always possible to use normal shell redirect such as: | ||
Line 22: | Line 21: | ||
Since file descriptors are used unless a command is ready to accept input from a file descriptor, it may not work. | Since file descriptors are used unless a command is ready to accept input from a file descriptor, it may not work. | ||
[[Main_Page|Home]] > [[Shell scripting]] > [[Shell operators]] > [[Read output of shell command from a file]] |
Latest revision as of 13:35, 7 April 2022
Home > Shell scripting > Shell operators > Read output of shell command from a file
It is always possible to use normal shell redirect such as:
ls > 1.txt ls -a > 2.txt diff 1.txt 2.txt
to get output of a command in a file and then give it as path to some other command.
But the same can be achieved using:
diff <(ls) <(ls -a)
What happens under the hood, is that two output file descriptors of the given commands are given to diff as input. Use:
echo diff <(ls) <(ls -a)
to understand this.
Since file descriptors are used unless a command is ready to accept input from a file descriptor, it may not work.
Home > Shell scripting > Shell operators > Read output of shell command from a file