1

I've installed some utilities from the CLI and got quite a long verbose output describe what was installed directly, what needed some dependencies, what is no longer needed to be installed, etc.

Is there a way to grep something from this last command ? A very certain word I need.

Thanks,

3
  • 1
    why dont you redirect the output to some files and grep your words from that file ?
    – Kamaraj
    Dec 27, 2016 at 1:30
  • That sounds good @Kamaraj, I would like to redirect it to a temporary file, then cat the file with a pipe, then grep the desired word.
    – user149572
    Dec 27, 2016 at 1:44
  • cat filename | grep "pattern" ...... grep itself can read the file.... so you can use like grep "pattern" filename.. if you use cat and grep, then you will get a "useless use of cat award" ( google it )
    – Kamaraj
    Dec 27, 2016 at 1:46

3 Answers 3

1
'your install command' > /tmp/out.txt 2>&1

then, use the /tmp/out.txt to grep the required patterns

grep "pattern" /tmp/out.txt

Redirect stderr to stdout (&1), and then redirect stdout to a file:

'your install command' > /tmp/out.txt 2>&1
2
  • Thanks. Can yu please an appendix at the end of the answer with an explanation about 2>&1? Seems to me like "append to a file descriptor different then 0 or 1, which is 2, and run in the background". I don't know what is 1 in the very end.
    – user149572
    Dec 27, 2016 at 2:14
  • its not about running background.. please refer this link
    – Kamaraj
    Dec 27, 2016 at 2:20
0

I needed something that does that after I ran the installation command, and not for to-come installation commands.

While I don't know a command to do it after the instillation command has been executed, what I did was to copy the output from Bash itself, into a text editor like Vi or Nano, and then search for all instances of the desired phrase.

0
0

The information might be in the log files of apt.

grep -Ri "pattern" /var/log/apt/*log

You must log in to answer this question.