Search code examples
linuxbashawksedcut

how can i cut off the strings from an output in Bash shell?


The command i run is as follows:

rpm -qi setup | grep Install

The output of the command:

Install Date: Do 30 Jul 2020 15:55:28 CEST

I would like to edit this output further more in order to remain with just: 30 Jul 2020

And the rest of the output not to be displayed.

What best editing way in bash can i possibly simply get this end result?


Solution

  • You can do it using just rpmqueryformat and bashprintf:

    $ printf '%(%d %b %Y)T\n' $(rpm -q --queryformat '%{INSTALLTIME}\n' setup)
    29 Apr 2020