this post was submitted on 01 Dec 2024
406 points (99.0% liked)
Bash
763 readers
7 users here now
Talk about the Bash Shell and Bash scripting
founded 4 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
another useful one is <(cmd here)
It's like $(cmd here) but instead of returning the output of the command as a string passed into the arguments, it makes a new file descriptor for the output of the command and returns the path to it, for use in commands that want a file as an argument.
So for example if you want to use diff to compare your local passwd file to a remote one..
diff -u <(ssh host1 cat /etc/passwd) /etc/passwd
Admittedly I can't think of many things I've used this for outside of diff and alternatives to diff..but I've used it there a lot, like comparing the results of running two slightly different queries.
I use this one for comm a lot. E.g.,
comm -12 <(sort some_file) <(grep foo some_other_file | sort)