If you type pacman -Qi <package name> you get information about the package in question. Within this information you get if this package conflicts with another installed package.
If I run pacman -Qdt I will get a list of packages that are no longer required as dependencies.
pacman -Qdt
| clutter-gst2 | 2.0.18-1 |
| geoclue | 0.12.99-2 |
| java-rxtx | 2.2pre2-3 |
| libftdi-compat | 0.20-3 |
| libirman | 0.5.2-1 |
| ppl | 1.2-1 |
| pth | 2.0.7-5 |
| python-path | 8.2.1-1 |
| python2-atspi | 2.20.2-1 |
| python2-path | 8.2.1-1 |
| spandsp | 0.0.6-1 |
| speech-dispatcher | 0.8.5-1 |
| wildmidi | 0.4.0-1 |
| wxgtk2.8 | 2.8.12.1-4 |
| zeitgeist | 0.9.16-1 |
Now if I would like to get the first column of this array I will type the following command.
pacman -Qdt | awk '{print $1}'
| clutter-gst2 |
| geoclue |
| java-rxtx |
| libftdi-compat |
| libirman |
| ppl |
| pth |
| python-path |
| python2-atspi |
| python2-path |
| spandsp |
| speech-dispatcher |
| wildmidi |
| wxgtk2.8 |
| zeitgeist |
I can now use nested awk and assign to the inner awk to execute a shell command using the sh -x. I will use the -k switch to verify the presence of the files installed by the package.
pacman -Qdt | awk '{print $1}' | awk '{print "pacman -Qk " $1}' | sh -x
| clutter-gst2: 47 total files | 0 missing files |
| geoclue: 109 total files | 0 missing files |
| java-rxtx: 20 total files | 0 missing files |
| libftdi-compat: 16 total files | 0 missing files |
| libirman: 30 total files | 0 missing files |
| ppl: 28 total files | 0 missing files |
| pth: 17 total files | 0 missing files |
| python-path: 19 total files | 0 missing files |
| python2-atspi: 77 total files | 0 missing files |
| python2-path: 18 total files | 0 missing files |
| spandsp: 157 total files | 0 missing files |
| speech-dispatcher: 111 total files | 0 missing files |
| wildmidi: 36 total files | 0 missing files |
| wxgtk2.8: 755 total files | 0 missing files |
| zeitgeist: 72 total files | 0 missing files |
A small trick is to use tr to alternate the format of the output to a single line. By doing so I can specify which package I would like to get to the output.
pacman -Qdt | awk '{print $1}' | tr '\n' ' ' | awk '{print "pacman -Ql " $4}' | sh -x
| libftdi-compat | usr |
| libftdi-compat | usr/bin |
| libftdi-compat | /usr/bin/libftdi-config |
| libftdi-compat | usr/include |
| libftdi-compat | /usr/include/ftdi.h |
| libftdi-compat | /usr/include/ftdi.hpp |
| libftdi-compat | usr/lib |
| libftdi-compat | /usr/lib/libftdi.so |
| libftdi-compat | /usr/lib/libftdi.so.1 |
| libftdi-compat | /usr/lib/libftdi.so.1.20.0 |
| libftdi-compat | /usr/lib/libftdipp.so |
| libftdi-compat | /usr/lib/libftdipp.so.1 |
| libftdi-compat | /usr/lib/libftdipp.so.1.20.0 |
| libftdi-compat | usr/lib/pkgconfig |
| libftdi-compat | /usr/lib/pkgconfig/libftdi.pc |
| libftdi-compat | /usr/lib/pkgconfig/libftdipp.pc |
Finally, to get the list of all packages and their conflicting packages I will pass the output to another awk which looks in the first, second and fourth column for the keywords "Name" and "Conflicts". Notice the in the second awk I have used $0 which indicates that I will get as input everything. This is a requirement because I have altered the format of the list to a single line using tr, which means that I have a bunch of columns.
pacman -Qdt | awk '{print $1}' | tr '\n' ' ' | awk '{print "pacman -Qi " $0}' | sh -x | awk '{print $1 "\t" $3 "\t" $4}' | grep "^Name\|^Conflicts" | column -t -s ':'
| Name | clutter-gst2 | |
| Conflicts | clutter-gst<=2.0.14 | |
| Name | geoclue | |
| Conflicts | None | |
| Name | java-rxtx | |
| Conflicts | None | |
| Name | libftdi-compat | |
| Conflicts | None | |
| Name | libirman | |
| Conflicts | None | |
| Name | ppl | |
| Conflicts | None | |
| Name | pth | |
| Conflicts | None | |
| Name | python-path | |
| Conflicts | None | |
| Name | python2-atspi | |
| Conflicts | pyatspi | |
| Name | python2-path | |
| Conflicts | None | |
| Name | spandsp | |
| Conflicts | None | |
| Name | speech-dispatcher | |
| Conflicts | None | |
| Name | wildmidi | |
| Conflicts | None | |
| Name | wxgtk2.8 | |
| Conflicts | None | |
| Name | zeitgeist | |
| Conflicts | zeitgeist-datahub |
Now to make the above look better you can use column, and sed commands.
pacman -Qdt | awk '{print $1}' | tr '\n' ' ' | awk '{print "pacman -Qi " $0}' | sh -x | awk '{print $1 "\t" $3 "\t" $4}' | grep "^Name\|^Conflicts" | column -x -s ':' | sed -r -e 's/\b(Name|Conflicts)\b//g' | tr '\t' ' ' | tr -d ':'
| clutter-gst2 | clutter-gst<=2.0.14 |
| geoclue | None |
| java-rxtx | None |
| libftdi-compat | None |
| libirman | None |
| ppl | None |
| pth | None |
| python-path | None |
| python2-atspi | pyatspi |
| python2-path | None |
| spandsp | None |
| speech-dispatcher | None |
| wildmidi | None |
| wxgtk2.8 | None |
| zeitgeist | zeitgeist-datahub |
pacman -Qdt | awk '{print $1}' | tr '\n' ' ' | awk '{print "pacman -Qi " $0}' | sh -x | awk '{print $1 "\t" $3 "\t" $4}' | grep "^Name\|^Conflicts" | column -x -s ':' | sed -r -e 's/\b(Name|Conflicts)\b//g' | tr '\t' ' ' | tr -d ':' | awk '$2 != "None" {print $0}'
| clutter-gst2 | clutter-gst<=2.0.14 |
| python2-atspi | pyatspi |
| zeitgeist | zeitgeist-datahub |
If you would like to do the same for all the packages use pacman -Qnq, and add the paste to merge lines in dyads.
pacman -Qnq | awk '{print $1}' | tr '\n' ' ' | awk '{print "pacman -Qi " $0}' | sh -x | awk '{print $1 "\t" $3 "\t" $4}' | grep "^Name\|^Conflicts" | column -x -s ':' | sed -r -e 's/\b(Name|Conflicts)\b//g' | tr '\t' ' ' | tr -d ':' | paste -d " " - - | awk '$2 != "None" {print $0}'
awk command take its arguments in columns, use $0 to get everything as input
tr can be used to reformat the output in shell scripts, and you can also delete characters using -d
sh -x execute commands from standard input, see documentation of set command for the -x switch
column command
sed -e is used for standard input
paste is used to merge lines