I mean, when I run
dpkg -s thunar | grep "Depends"
it displays all dependencies for thunar file manager. How to run, for example
dpkg -s thunar | grep "Depends" | grep "gtk"
to display only dependencies containing gtk in its name ?
I mean, when I run
dpkg -s thunar | grep "Depends"
it displays all dependencies for thunar file manager. How to run, for example
dpkg -s thunar | grep "Depends" | grep "gtk"
to display only dependencies containing gtk in its name ?
I would split up the packages in separate lines to be
grep
ped withtr
:grep
deals with lines, so after initial match forDepends
line, you need to split the line somehow. It can be done withgrep -Po
flags, but that can be slightly complex. A simpler way and only via one pipeline is to useawk
:This matches appropriate line and iterates over each "field" or space-separated column in the line, checking if it contains
gtk
.The way you type your example should also work but you can do...
... if gtk is always after Depends
Example:
Explanation:
-o
- Print only the matching part of the line\S*
- Zero or more non-whitespace charactersIf you want the version number too:
[^,]*
- Zero or more characters which are not commas