Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first problem here is that not every command has a --help option!! In fact the very first command, accept, has no such option! A better approach might be executing man on each command since a manual page is more likely to exist for each of the commands. Thus change;</p> <pre><code>$i --help | less | cat &gt; masterlinuxnow </code></pre> <p>to </p> <pre><code>man $i &gt;&gt; masterlinuxnow </code></pre> <p>note that it is essential you use the append output operator ">>" instead of the create output operator ">" in this loop. Using the create output operator will recreate the file "masterlinuxnow" on each iteration thus containing only the output of the last "man $i" processed.</p> <p>you also need to worry about whether the command exists on your version of linux (many commands are not included in the standard distribution or may have different names). Thus you probably want something more like this where the -n in the head command should be replace by the number of lines you want, so if you want only the first 2 lines of the --help output you would replace -n with -2:</p> <pre><code>if [ $(which $i) ] then $i --help | head -n &gt;&gt; masterlinuxnow fi </code></pre> <p>and instead of the read command, simply define the variable commands like so:</p> <pre><code>commands=" bison bzcmp bzdiff bzgrep bzip2 bzless bzmore c++ lastb lastlog strace strfile zmore znew " </code></pre> <p>Putting this all together, the following script works quite nicely:</p> <pre><code>commands=" bison bzcmp bzdiff bzgrep bzip2 bzless bzmore c++ lastb lastlog strace strfile zmore znew " for i in $commands do if [ $(which $i) ] then $i --help | head -1 &gt;&gt; masterlinuxnow 2&gt;/dev/null fi done </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload