Open main menu

CDOT Wiki β

Changes

OPS235 Lab 4 - CentOS7

804 bytes removed, 20:10, 10 April 2015
no edit summary
::  esac
</code>
<ol><li value="6">Save your editing session, but remain in the text editor.</li><li>The code displayed below uses a trick called the "Here Document" logic to redirect stdin from within exit the command (a quick way to display output on script if the screen)input file does not exist. The read command will Command substitution is used to store each line of the different information report items input file as words a positional parameter, and then a for loop (separated by a spacefor each positional parameter). The sed command is used to convert the spaces to pipes create each account (|useradd) and stored into another variable. This allows mail the sed command to use extended regular expressions to print rpm elements that match those various patterns to be added to the reportuser their account information (mail). Add the following code:</li></ol>
<br>
<code style="color:#3366CC;font-family:courier;font-size:.9em;">
::&#35; Clear screen and use Here Document to display select on report items to read into variable<br><br>
::cat &lt;&lt;+
::Available Package Information Items:
::Name::Summary::Version::License::Source::URL::+::read -p "Enter word(s) shown above separated by spaces: " choice<br><br>::&#35; Convert spaces to pipe symbol (|)::processedChoice=$(echo $choice | sed 's/ /|/g')<br><br>::&#35; Use sed with extended regular expressions to only print those matching report elements::rpm -qi $1 | sed -r -n "/($processedChoice)/ p" &gt;&gt; /root/package-info.txt<br><br>::cat &lt;&lt;+::File "/root/package-info.txt" can been created::+
</code>
13,420
edits