Changes

Jump to: navigation, search

OPS245 Lab 3

246 bytes added, 10:06, 5 October 2021
Part 3: Using sed to Filter Output from Commands
<br>
<code><span style="color:#3366CC;font-size:1.1em;"><b>
&#35; Use sed with extended regular expressions to only print those matching report elements<br>
rpm -qi xchat
</b></span></code><<br />Notice that using the '''-i ''' option with '''-q ''' causes rpm to generate more output than we have seen from it so far.</li><li>Pick any five packages and run the <code><span style="color:#3366CC;font-size:1.1em;"><b>rpm -qi</b></span></code> command on all five at once. This should produce dozens of lines of output. Consider the output it would generate if we used -a instead of picking just a few packages.<li><li>Run <code><span style="color:#3366CC;font-size:1.1em;"><b>rpm -qia</b></span></code> now.)</li>
<li>That is way too much output for us to reasonably search through, but we have commands that can filter this down to a much more readable amount.</li>
<li>Try the command: <br><code><span style="color:#3366CC;font-size:1.1em;"><b>rpm -qia | sed -nre '/^Name&#91;&#91;:space:&#93;&#93;+:/ p' -e '/^Install Date&#91;&#91;:space:&#93;&#93;*:/ p'</b></span></code><br />
Instead of printing every line, this will only display the name and install date of each package.</li>
<li>Try modifying that command to display only the package name Name and License.</li>
</ol>
572
edits

Navigation menu