Comments on When a command takes filenames as argument, how can I avoid creating temporary files?
Parent
When a command takes filenames as argument, how can I avoid creating temporary files?
+1
−0
Suppose I have a command that takes filenames as arguments, like: diff foo.txt bar.txt
What if instead of actual files, I want to use the results of a command in each?
I can use temporary files:
ls /home/alice > /tmp/alice.txt
ls /home/bob > /tmp/bob.txt
diff alice.txt bob.txt
But what if I don't want to create the files?
Post
+5
−0
What you're looking for is called process substitution.
In Bash and many bash-like shells, you can use <(foo_command --with --arguments)
instead of the file path:
diff <(ls /home/alice) <(ls /home/bob)
0 comment threads