Search code examples
bashgrepgentoo

How to grep a line followed by a newline from output in terminal


I have the following output on my terminal

* These packages depend on app-portage/gentoolkit-0.6.5:

 * These packages depend on app-portage/getuto-1.11:
sys-apps/portage-3.0.63 (!build ? app-portage/getuto)

 * These packages depend on app-portage/portage-utils-0.96.1:
app-admin/perl-cleaner-2.31 (!pkgcore ? app-portage/portage-utils)

How do I only grep lines such as gentoolkit that have no lines following it?

What I have tried : some command | xargs grep -eF ".*\n\n"
But this returns File or Directory not found.

What I am trying to achieve?
In gentoo linux, eix-installed -a | xargs equery depends gives the dependency for all packages. I want to find the ones that have no dependencies listed.


Solution

  • Although @oguz-ismail's answer would work with the sample output provided, it seems that actual equery output becomes garbled when it is fed into a pipe.

    This convoluted commandline seems to work around the problems:

    </dev/null script -B /dev/null -f -q -c '
        eix-installed -a | xargs equery depends
    ' |
    tr -d '\r' |
    grep -v '^---' |
    awk '!/\n/' RS=