bash tricks
bash tricks
bash tricks
You're viewing a single thread.
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)