linuxbashshellarchlinuxcomm

GNU/Linux using comm with a file and the output of a command


I want to use the comm command to compare a text file and the output of a command.

My first idea was to run:

comm packagesList $(pacman -Qe)

However, that outputs an errpr. I also tried using ´pacman -Qe´ just in case, but I still get the same error. Is there a way for me to compare the contents of the text file packagesList against the output of the pacman -Qe command?


Solution

  • pacman -Qe | comm packagesList -
    

    or

    comm packagesList <(pacman -Qe)
    

    Topics to research: what are standard streams and stdin/stderr/stdout, man comm -> When FILE1 or FILE2 (not both) is -, read standard input, what are command substitution and process substitution terms in shell context.