SEESenv/web/html/chn11Section_5.html
author amit@thunder
Tue, 23 Feb 2010 19:43:04 +0530
changeset 25 ed38dd9bdb50
parent 16 2e3d2cadbcb6
child 27 cb14131583c6
permissions -rw-r--r--
New build of html solving some of the bugs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
672eaaab9204 Added some new html files that failed earlier during change from rst
amit@thunder
parents:
diff changeset
     1
<html>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
     2
 <head>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
     3
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
     4
  <title>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
     5
   Chapter. Section_
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
     6
  </title>
15
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
     7
  <link rel="stylesheet" href="/review/support/styles.css" type="text/css" />
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
     8
  <meta name="generator" content="DocBook XSL Stylesheets V1.74.3" />
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
     9
  <link rel="shortcut icon" type="image/png" href="/review/support/figs/favicon.png" />
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
    10
  <script type="text/javascript" src="/review/support/jquery-min.js">
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
    11
  </script>
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
    12
  <script type="text/javascript" src="/review/support/form.js">
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
    13
  </script>
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
    14
  <script type="text/javascript" src="/review/support/hsbook.js">
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
    15
  </script>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    16
 </head>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    17
 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
16
2e3d2cadbcb6 Testing
amit@thunder
parents: 15
diff changeset
    18
  <div class="chapter" id="ch11Section_5">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    19
   <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    20
   </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    21
   <div class="toc">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    22
    <p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    23
     <b>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    24
      Table of Contents
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    25
     </b>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    26
    </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    27
    <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    28
     <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    29
      <span class="article">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    30
       <a href="#id2805047">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    31
       </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    32
      </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    33
     </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    34
     <dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    35
      <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    36
       <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    37
        <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    38
         <a href="#id2615138">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    39
          1. Module Objectives:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    40
         </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    41
        </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    42
       </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    43
       <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    44
        <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    45
         <a href="#id2803399">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    46
          2. tar:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    47
         </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    48
        </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    49
       </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    50
       <dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    51
        <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    52
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    53
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    54
           <a href="#id2803952">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    55
            2.1. Introduction:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    56
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    57
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    58
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    59
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    60
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    61
           <a href="#id2856019">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    62
            2.2. Getting Started(go go go!):
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    63
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    64
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    65
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    66
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    67
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    68
           <a href="#id2856298">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    69
            2.3. Further Reading for this section:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    70
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    71
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    72
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    73
        </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    74
       </dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    75
       <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    76
        <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    77
         <a href="#id2856343">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    78
          3. GZip:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    79
         </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    80
        </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    81
       </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    82
       <dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    83
        <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    84
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    85
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    86
           <a href="#id2856368">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    87
            3.1. Get going:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    88
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    89
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    90
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    91
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    92
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    93
           <a href="#id2856622">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
    94
            3.2. Further Reading for this section:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    95
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    96
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    97
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    98
        </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
    99
       </dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   100
       <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   101
        <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   102
         <a href="#id2856676">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   103
          4. File Comparisons:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   104
         </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   105
        </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   106
       </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   107
       <dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   108
        <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   109
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   110
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   111
           <a href="#id2856693">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   112
            4.1. cmp:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   113
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   114
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   115
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   116
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   117
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   118
           <a href="#id2856735">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   119
            4.2. diff:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   120
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   121
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   122
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   123
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   124
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   125
           <a href="#id2856817">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   126
            4.3. comm:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   127
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   128
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   129
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   130
        </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   131
       </dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   132
       <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   133
        <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   134
         <a href="#id2856847">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   135
          5. Environment Variables:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   136
         </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   137
        </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   138
       </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   139
       <dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   140
        <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   141
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   142
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   143
           <a href="#id2856946">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   144
            5.1. Further Reading:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   145
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   146
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   147
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   148
        </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   149
       </dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   150
       <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   151
        <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   152
         <a href="#id2857001">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   153
          6. Shell Scripting:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   154
         </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   155
        </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   156
       </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   157
       <dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   158
        <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   159
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   160
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   161
           <a href="#id2857009">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   162
            6.1. Basics:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   163
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   164
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   165
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   166
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   167
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   168
           <a href="#id2855367">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   169
            6.2. Shell Arithmetic:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   170
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   171
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   172
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   173
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   174
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   175
           <a href="#id2857386">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   176
            6.3. if else construct:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   177
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   178
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   179
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   180
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   181
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   182
           <a href="#id2857492">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   183
            6.4. Loops
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   184
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   185
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   186
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   187
         <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   188
          <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   189
           <a href="#id2857738">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   190
            6.5. Functions
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   191
           </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   192
          </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   193
         </dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   194
         <dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   195
          <span class="section">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   196
           <a href="#id2857809">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   197
            6.6. Further Reading:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   198
           </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   199
          </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   200
         </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   201
        </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   202
       </dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   203
      </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   204
     </dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   205
    </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   206
   </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   207
   <div class="article">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   208
    <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   209
     <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   210
      <div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   211
       <h2 class="title" id="id2805047">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   212
       </h2>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   213
      </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   214
      <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   215
       <h2 class="title" id="id2805047">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   216
       </h2>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   217
      </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   218
     </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   219
     <hr />
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   220
    </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   221
    <div class="toc">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   222
     <p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   223
      <b>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   224
       Table of Contents
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   225
      </b>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   226
     </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   227
     <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   228
      <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   229
       <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   230
        <a href="#id2615138">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   231
         1. Module Objectives:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   232
        </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   233
       </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   234
      </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   235
      <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   236
       <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   237
        <a href="#id2803399">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   238
         2. tar:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   239
        </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   240
       </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   241
      </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   242
      <dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   243
       <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   244
        <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   245
         <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   246
          <a href="#id2803952">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   247
           2.1. Introduction:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   248
          </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   249
         </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   250
        </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   251
        <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   252
         <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   253
          <a href="#id2856019">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   254
           2.2. Getting Started(go go go!):
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   255
          </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   256
         </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   257
        </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   258
        <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   259
         <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   260
          <a href="#id2856298">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   261
           2.3. Further Reading for this section:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   262
          </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   263
         </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   264
        </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   265
       </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   266
      </dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   267
      <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   268
       <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   269
        <a href="#id2856343">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   270
         3. GZip:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   271
        </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   272
       </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   273
      </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   274
      <dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   275
       <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   276
        <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   277
         <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   278
          <a href="#id2856368">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   279
           3.1. Get going:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   280
          </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   281
         </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   282
        </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   283
        <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   284
         <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   285
          <a href="#id2856622">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   286
           3.2. Further Reading for this section:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   287
          </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   288
         </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   289
        </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   290
       </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   291
      </dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   292
      <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   293
       <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   294
        <a href="#id2856676">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   295
         4. File Comparisons:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   296
        </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   297
       </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   298
      </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   299
      <dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   300
       <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   301
        <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   302
         <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   303
          <a href="#id2856693">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   304
           4.1. cmp:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   305
          </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   306
         </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   307
        </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   308
        <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   309
         <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   310
          <a href="#id2856735">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   311
           4.2. diff:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   312
          </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   313
         </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   314
        </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   315
        <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   316
         <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   317
          <a href="#id2856817">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   318
           4.3. comm:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   319
          </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   320
         </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   321
        </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   322
       </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   323
      </dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   324
      <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   325
       <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   326
        <a href="#id2856847">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   327
         5. Environment Variables:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   328
        </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   329
       </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   330
      </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   331
      <dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   332
       <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   333
        <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   334
         <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   335
          <a href="#id2856946">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   336
           5.1. Further Reading:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   337
          </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   338
         </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   339
        </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   340
       </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   341
      </dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   342
      <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   343
       <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   344
        <a href="#id2857001">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   345
         6. Shell Scripting:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   346
        </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   347
       </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   348
      </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   349
      <dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   350
       <dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   351
        <dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   352
         <span class="section">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   353
          <a href="#id2857009">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   354
           6.1. Basics:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   355
          </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   356
         </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   357
        </dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   358
        <dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   359
         <span class="section">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   360
          <a href="#id2855367">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   361
           6.2. Shell Arithmetic:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   362
          </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   363
         </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   364
        </dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   365
        <dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   366
         <span class="section">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   367
          <a href="#id2857386">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   368
           6.3. if else construct:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   369
          </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   370
         </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   371
        </dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   372
        <dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   373
         <span class="section">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   374
          <a href="#id2857492">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   375
           6.4. Loops
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   376
          </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   377
         </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   378
        </dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   379
        <dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   380
         <span class="section">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   381
          <a href="#id2857738">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   382
           6.5. Functions
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   383
          </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   384
         </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   385
        </dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   386
        <dt>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   387
         <span class="section">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   388
          <a href="#id2857809">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   389
           6.6. Further Reading:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   390
          </a>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   391
         </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   392
        </dt>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   393
       </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   394
      </dd>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   395
     </dl>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   396
    </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   397
    <div class="section" title="1.Module Objectives:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   398
     <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   399
      <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   400
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   401
        <h2 class="title" style="clear: both">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   402
         <a name="id2615138">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   403
         </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   404
         1.Module Objectives:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   405
        </h2>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   406
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   407
      </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   408
     </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   409
     <p id="ch11Section_5_1">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   410
      After successfully completing this module a participant will be able to:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   411
     </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   412
     <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   413
      - Understand
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   414
  * What are archives and zipped files                              U
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   415
  * What are environment variables                                  U
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   416
  * What are Shell Scripts                                          U
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   417
- Able to use file comparison commands like                         Ap
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   418
  diff, cmp, comm
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   419
- Create and extract archives(.tar files) and zipped files(.gz)     Ap
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   420
- Set/Modify environment as per need                                Ap
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   421
- Create shell scripts to automate tasks.                           Ap
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   422
     </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   423
    </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   424
    <div class="section" title="2.tar:">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   425
     <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   426
      <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   427
       <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   428
        <h2 class="title" style="clear: both">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   429
         <a name="id2803399">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   430
         </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   431
         2.tar:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   432
        </h2>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   433
       </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   434
      </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   435
     </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   436
     <div class="section" title="2.1.Introduction:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   437
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   438
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   439
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   440
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   441
          <a name="id2803952">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   442
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   443
          2.1.Introduction:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   444
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   445
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   446
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   447
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   448
      <p id="ch11Section_5_2">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   449
       In world of Linux based distribution,
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   450
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   451
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   452
         tarballs
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   453
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   454
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   455
       is the term which pops up very often. It is part of the GNU project and comes as part of every distribution of GNU/Linux. Tarball is like defacto standard for releasing source code for free software. Some of common use of
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   456
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   457
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   458
         tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   459
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   460
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   461
       archives is to:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   462
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   463
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   464
         Store, backup, and transport
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   465
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   466
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   467
       .
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   468
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   469
      <p id="ch11Section_5_3">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   470
       GNU tar creates and manipulates archives which are actually collections of many other files; the program provides users with an organized and systematic method for controlling a large amount of data. It is basically form of creating archive by concatenating one or more files.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   471
      </p>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   472
     </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   473
     <div class="section" title="2.2.Getting Started(go go go!):">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   474
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   475
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   476
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   477
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   478
          <a name="id2856019">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   479
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   480
          2.2.Getting Started(go go go!):
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   481
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   482
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   483
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   484
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   485
      <p id="ch11Section_5_4">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   486
       As mentioned previously and if not,
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   487
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   488
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   489
         The best way to get started with any command line tool of Linux is to use "man".
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   490
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   491
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   492
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   493
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   494
       $ man tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   495
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   496
      <p id="ch11Section_5_5">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   497
       or try these commands(the output may vary with different installations):
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   498
      </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   499
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   500
       $ tar --version
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   501
tar (GNU tar) 1.20
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   502
Copyright (C) 2008 Free Software Foundation, Inc.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   503
License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   504
This is free software: you are free to change and redistribute it.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   505
There is NO WARRANTY, to the extent permitted by law.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   506
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   507
Written by John Gilmore and Jay Fenlason.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   508
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   509
$ tar --help
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   510
Usage: tar [OPTION...] [FILE]...
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   511
GNU `tar' saves many files together into a single tape or disk archive, and can
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   512
restore individual files from the archive.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   513
Examples:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   514
tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   515
tar -tvf archive.tar         # List all files in archive.tar verbosely.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   516
tar -xf archive.tar          # Extract all files from archive.tar.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   517
____________
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   518
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   519
      <div class="section" title="2.2.1.Creating a tar archive:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   520
       <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   521
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   522
         <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   523
          <h4 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   524
           <a name="id2856073">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   525
           </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   526
           2.2.1.Creating a tar archive:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   527
          </h4>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   528
         </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   529
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   530
       </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   531
       <p id="ch11Section_5_6">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   532
        We will do some off-the road activity for this exercise. We will use an interesting command
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   533
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   534
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   535
          fortune
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   536
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   537
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   538
        for creating our practice files and then performing archives of those files and directories. Content of the files would vary for users, as fortune works like that.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   539
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   540
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   541
        $ mkdir fortune-files
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   542
$ cd fortune-files/
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   543
$ fortune &gt; first.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   544
$ cat first.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   545
Expect the worst, it's the least you can do.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   546
$ fortune &gt; second.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   547
$ fortune &gt; third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   548
$ ls
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   549
first.txt  second.txt  third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   550
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   551
       <p id="ch11Section_5_7">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   552
        By now we have three txt files, with some random fortune content. To create a tar archive of these files we can use any of following commands according to ones convenience:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   553
       </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   554
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   555
        $ tar --create --verbose --file=allfiles.tar first.txt second.txt third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   556
first.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   557
second.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   558
third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   559
$ ls
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   560
allfiles.tar  first.txt  second.txt  third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   561
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   562
       <p id="ch11Section_5_8">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   563
        allfiles.tar is our required tar archive of all the rest of files(or archive of files mentioned in command line). Other form of the previous command are:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   564
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   565
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   566
        $ tar -c -v -f allfiles.tar first.txt second.txt third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   567
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   568
       <p id="ch11Section_5_9">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   569
        or
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   570
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   571
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   572
        $ tar -cvf allfiles.tar first.txt second.txt third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   573
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   574
       <p id="ch11Section_5_a">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   575
        The general format for creating a tar archive is:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   576
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   577
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   578
        tar [OPTION...] [FILE]...
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   579
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   580
       <p id="ch11Section_5_b">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   581
        For our command are using these options:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   582
       </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   583
       <div class="itemizedlist">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   584
        <ul class="itemizedlist" type="*">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   585
         <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   586
          <p id="ch11Section_5_c">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   587
           -c to Create the archive.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   588
          </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   589
         </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   590
         <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   591
          <p id="ch11Section_5_d">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   592
           -v for Verbose mode, to get the names of the files as they are archived.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   593
          </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   594
         </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   595
         <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   596
          <p id="ch11Section_5_e">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   597
           -f mentioning the file name of the resulting tar archive.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   598
          </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   599
         </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   600
        </ul>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   601
       </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   602
       <p id="ch11Section_5_f">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   603
        To create archive of folder itself try this:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   604
       </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   605
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   606
        $ tar -cvf fortune.tar fortune/
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   607
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   608
       <p id="ch11Section_5_10">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   609
        To add files to existing tar archive, option
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   610
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   611
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   612
          `r`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   613
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   614
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   615
        is used:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   616
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   617
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   618
        $ fortune &gt; fourth.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   619
$ tar -r fourth.txt -vf allfiles.tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   620
fourth.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   621
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   622
       <p id="ch11Section_5_11">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   623
        There are other options too available for explicitly mentioning the position of archive, use
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   624
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   625
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   626
          tar --help
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   627
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   628
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   629
        for getting all the details.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   630
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   631
       <p id="ch11Section_5_12">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   632
        Similarly to remove file from archive use
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   633
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   634
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   635
          --delete
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   636
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   637
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   638
        option:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   639
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   640
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   641
        $ tar --delete second.txt -f allfiles.tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   642
$ tar -tf allfiles.tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   643
first.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   644
third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   645
fourth.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   646
       </pre>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   647
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   648
      <div class="section" title="2.2.2.Listing the files of archive:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   649
       <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   650
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   651
         <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   652
          <h4 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   653
           <a name="id2856213">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   654
           </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   655
           2.2.2.Listing the files of archive:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   656
          </h4>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   657
         </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   658
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   659
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   660
       <p id="ch11Section_5_13">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   661
        Once files are archived, tar command have the
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   662
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   663
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   664
          `t`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   665
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   666
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   667
        option, for Listing all files in the tar file:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   668
       </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   669
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   670
        $ tar tf allfiles.tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   671
first.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   672
second.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   673
third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   674
       </pre>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   675
       <p id="ch11Section_5_14">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   676
        <span class="strong">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   677
         <strong>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   678
          //this is not working for me in some cases :(
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   679
         </strong>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   680
        </span>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   681
       </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   682
       <p id="ch11Section_5_15">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   683
        To locate a particular file among the archive mention its name after
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   684
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   685
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   686
          t
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   687
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   688
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   689
        option.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   690
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   691
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   692
        $ tar t second.txt allfiles.tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   693
second.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   694
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   695
       <p id="ch11Section_5_16">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   696
        one can also use elementary regex for locating the file, so in previous case even second.* will also return the same result.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   697
       </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   698
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   699
      <div class="section" title="2.2.3.Extracting files from archive:">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   700
       <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   701
        <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   702
         <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   703
          <h4 class="title">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   704
           <a name="id2856263">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   705
           </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   706
           2.2.3.Extracting files from archive:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   707
          </h4>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   708
         </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   709
        </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   710
       </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   711
       <p id="ch11Section_5_17">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   712
        To extract the content from a archive, use
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   713
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   714
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   715
          `x`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   716
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   717
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   718
        option:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   719
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   720
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   721
        $ mkdir extract
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   722
$ cp allfiles.tar extract/
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   723
$ cd extract
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   724
$ tar -xvf allfiles.tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   725
first.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   726
second.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   727
third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   728
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   729
       <p id="ch11Section_5_18">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   730
        To extract any particular file from archive, mention the name of file after
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   731
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   732
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   733
          x
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   734
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   735
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   736
        option:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   737
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   738
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   739
        $ tar -x second.txt -vf allfiles.tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   740
second.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   741
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   742
      </div>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   743
     </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   744
     <div class="section" title="2.3.Further Reading for this section:">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   745
      <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   746
       <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   747
        <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   748
         <h3 class="title">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   749
          <a name="id2856298">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   750
          </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   751
          2.3.Further Reading for this section:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   752
         </h3>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   753
        </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   754
       </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   755
      </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   756
      <div class="itemizedlist">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   757
       <ul class="itemizedlist" type="*">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   758
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   759
         <p id="ch11Section_5_19">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   760
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   761
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   762
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   763
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   764
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   765
          http://en.wikipedia.org/wiki/Tar_(file_format
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   766
         </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   767
         <p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   768
          )
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   769
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   770
        </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   771
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   772
         <p id="ch11Section_5_1a">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   773
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   774
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   775
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   776
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   777
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   778
          http://www.gnu.org/software/tar/manual/tar.html
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   779
         </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   780
        </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   781
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   782
         <p id="ch11Section_5_1b">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   783
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   784
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   785
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   786
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   787
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   788
          http://linuxreviews.org/beginner/
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   789
         </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   790
        </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   791
       </ul>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   792
      </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   793
     </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   794
    </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   795
    <div class="section" title="3.GZip:">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   796
     <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   797
      <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   798
       <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   799
        <h2 class="title" style="clear: both">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   800
         <a name="id2856343">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   801
         </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   802
         3.GZip:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   803
        </h2>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   804
       </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   805
      </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   806
     </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   807
     <p id="ch11Section_5_1c">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   808
      Tar creates archives but it does not compress data by itself unless specified explicitly. Hence all the archive we create using tar command, is simply of the size of total size of all individual files. With Linux there is a compression tool known as
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   809
      <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   810
       <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   811
        gzip
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   812
       </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   813
      </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   814
      which is used to reduce the size of files mentioned. Whenever possible, each file is replaced by one with the extension .gz', so unlike `tar this command would
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   815
      <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   816
       <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   817
        replace the existing file
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   818
       </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   819
      </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   820
      .
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   821
     </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   822
     <div class="section" title="3.1.Get going:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   823
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   824
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   825
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   826
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   827
          <a name="id2856368">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
   828
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   829
          3.1.Get going:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   830
         </h3>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   831
        </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   832
       </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   833
      </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   834
      <p id="ch11Section_5_1d">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   835
       As usual first commands to check out with gzip are
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   836
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   837
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   838
         man
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   839
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   840
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   841
       and
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   842
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   843
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   844
         help
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   845
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   846
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   847
       ,
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   848
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   849
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   850
       $ man gzip
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   851
$ gzip --help
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   852
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   853
      <p id="ch11Section_5_1e">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   854
       Creating a zip of a bunch of files is fairly trivial, it can be done simply via:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   855
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   856
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   857
       $ gzip [OPTION]... [FILE]...
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   858
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   859
      <div class="section" title="3.1.1.Creating zip files:">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   860
       <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   861
        <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   862
         <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   863
          <h4 class="title">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   864
           <a name="id2856399">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   865
           </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   866
           3.1.1.Creating zip files:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   867
          </h4>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   868
         </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   869
        </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   870
       </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   871
       <p id="ch11Section_5_1f">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   872
        Continuing from previous set of files and setup, we will like to zip them and hence the command would be:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   873
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   874
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   875
        $ gzip first.txt fourth.txt second.txt third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   876
$ ls
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   877
allfiles.tar  first.txt.gz  fourth.txt.gz  second.txt.gz  third.txt.gz  zipped.tar.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   878
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   879
       <p id="ch11Section_5_20">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   880
        Hence, as mentioned above, all original files are replaced by .gz extension. The above task can also be restated and made easy with help of some common regex expression:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   881
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   882
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   883
        $ gzip *.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   884
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   885
       <p id="ch11Section_5_21">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   886
        Similar to
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   887
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   888
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   889
          tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   890
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   891
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   892
        command, one can also use
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   893
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   894
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   895
          `-v`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   896
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   897
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   898
        option here to see the output in
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   899
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   900
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   901
          verbose
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   902
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   903
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   904
        form. For the previous example, if we enable this option the result would be something like this:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   905
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   906
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   907
        $ gzip -v *.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   908
first.txt:    4.4% -- replaced with first.txt.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   909
fourth.txt:  -7.1% -- replaced with fourth.txt.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   910
second.txt:  -4.8% -- replaced with second.txt.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   911
third.txt:    3.8% -- replaced with third.txt.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   912
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   913
       <p id="ch11Section_5_22">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   914
        For files of very small sizes and some other cases, one might end up with a zipped file whose size is greater then original file, but compression is always performed(so don't be disheartened in the above case, as files are larger :P). So unlike tar, here all files are zipped separately by default, to make them part of one single chunk one can use some
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   915
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   916
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   917
          pipes
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   918
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   919
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   920
        and
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   921
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   922
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   923
          redirections
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   924
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   925
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   926
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   927
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   928
        $ gzip -c *.txt &gt; all.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   929
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   930
       <p id="ch11Section_5_23">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   931
        Now in this case, all files would be zipped, concatenated and then the output would be written to a file all.gz leaving back all the original files. In the command above
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   932
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   933
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   934
          `-c`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   935
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   936
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   937
        option states to print the output to standard output(stdout) and following
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   938
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   939
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   940
          `&gt;`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   941
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   942
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   943
        would redirect the output to file all.gz. So when we decompress this file, we will get a single file named 'all' with all the content of each files concatenated one after the another.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   944
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   945
       <p id="ch11Section_5_24">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   946
        For creating a zip archive of a complete directory, one has to use
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   947
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   948
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   949
          `-r`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   950
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   951
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   952
        options which means recursive, it makes gzip to traverse through all directory tree/structure. By default it will create zip files of each file inside the directory, that is even with the -r flag, gzip still compresses one file at a time :
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   953
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   954
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   955
        $ gzip -r fortune-files/
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   956
$ gzip -rv .
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   957
./first.txt:          4.4% -- replaced with ./first.txt.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   958
./second.txt:        -4.8% -- replaced with ./second.txt.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   959
./third.txt:          3.8% -- replaced with ./third.txt.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   960
./allfiles.tar:      96.6% -- replaced with ./allfiles.tar.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   961
./fourth.txt:        -7.1% -- replaced with ./fourth.txt.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   962
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   963
       <p id="ch11Section_5_25">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   964
        Hence one always sees files like xxxxx.tar.gz, to create a zip of whole directory in a single file, first archive everything inside a folder and then use gzip on that. For zipping the files using tar itself, one has to use the option
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   965
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   966
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   967
          `g`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   968
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   969
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   970
        .
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   971
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   972
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   973
        $ tar -cvzf zipped.tar.gz *.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   974
first.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   975
fourth.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   976
second.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   977
third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   978
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   979
       <p id="ch11Section_5_26">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   980
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   981
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   982
          Thats why gzip is designed as a complement to tar, not as a replacement.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   983
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   984
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   985
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   986
       <p id="ch11Section_5_27">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   987
        gzip command comes with a option
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   988
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   989
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   990
          `-l`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   991
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   992
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   993
        to view the compressed file contents:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   994
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   995
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   996
        $ gzip -l zipped.tar.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   997
         compressed        uncompressed  ratio uncompressed_name
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   998
            332               10240      97.0% zipped.tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
   999
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1000
       <p id="ch11Section_5_28">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1001
        Other feature of gzip is option for mentioning the kind of compression one wants. There is a option of
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1002
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1003
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1004
          `-n`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1005
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1006
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1007
        where
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1008
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1009
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1010
          n varies from 0 to 9
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1011
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1012
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1013
        which regulate the speed/quality of compression. With
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1014
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1015
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1016
          `-1`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1017
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1018
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1019
        or
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1020
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1021
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1022
          `--fast`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1023
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1024
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1025
        option it means the fastest compression method (less compression) and
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1026
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1027
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1028
          `--best`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1029
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1030
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1031
        or
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1032
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1033
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1034
          `-9`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1035
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1036
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1037
        indicates the slowest compression method, default compression level is
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1038
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1039
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1040
          `-6`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1041
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1042
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1043
        .
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1044
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1045
       <p id="ch11Section_5_29">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1046
        To decompress a already compressed file there are two options, either use
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1047
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1048
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1049
          `gunzip`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1050
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1051
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1052
        command or use
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1053
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1054
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1055
          `-d`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1056
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1057
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1058
        option with gzip command:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1059
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1060
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1061
        $ gzip -dv *.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1062
all.gz:     -440.4% -- replaced with all
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1063
first.txt.gz:         4.4% -- replaced with first.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1064
fourth.txt.gz:       -7.1% -- replaced with fourth.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1065
second.txt.gz:       -4.8% -- replaced with second.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1066
third.txt.gz:         3.8% -- replaced with third.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1067
zipped.tar.gz:       97.0% -- replaced with zipped.tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1068
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1069
       <p id="ch11Section_5_2a">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1070
        or:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1071
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1072
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1073
        $ gunzip -v *.gz
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1074
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1075
       <p id="ch11Section_5_2b">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1076
        Both of those commands will give the same result. So here one can notice the content of file "all" which we created earlier, it will have content of all the rest of four files concatenated one after another, but "zipped.tar.gz" is zip of tar of all files, will effectively have zip of archives of all files separately, and hence the usage and importance of
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1077
        <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1078
         <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1079
          tar
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1080
         </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1081
        </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1082
        .
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1083
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1084
      </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1085
     </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1086
     <div class="section" title="3.2.Further Reading for this section:">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1087
      <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1088
       <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1089
        <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1090
         <h3 class="title">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1091
          <a name="id2856622">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1092
          </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1093
          3.2.Further Reading for this section:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1094
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1095
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1096
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1097
      </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1098
      <div class="itemizedlist">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1099
       <ul class="itemizedlist" type="*">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1100
        <li class="listitem" style="list-style-type: *">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1101
         <p id="ch11Section_5_2c">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1102
         </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1103
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1104
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1105
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1106
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1107
          http://linuxreviews.org/beginner/
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1108
         </div>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1109
        </li>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1110
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1111
         <p id="ch11Section_5_2d">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1112
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1113
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1114
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1115
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1116
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1117
          http://lowfatlinux.com/linux-gzip-gunzip.html
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1118
         </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1119
        </li>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1120
        <li class="listitem" style="list-style-type: *">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1121
         <p id="ch11Section_5_2e">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1122
         </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1123
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1124
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1125
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1126
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1127
          http://www.gnu.org/software/gzip/manual/gzip.html
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1128
         </div>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1129
        </li>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1130
        <li class="listitem" style="list-style-type: *">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1131
         <p id="ch11Section_5_2f">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1132
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1133
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1134
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1135
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1136
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1137
          http://en.wikipedia.org/wiki/ZIP_(file_format
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1138
         </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1139
         <p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1140
          )
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1141
         </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1142
        </li>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1143
       </ul>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1144
      </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1145
     </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1146
    </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1147
    <div class="section" title="4.File Comparisons:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1148
     <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1149
      <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1150
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1151
        <h2 class="title" style="clear: both">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1152
         <a name="id2856676">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1153
         </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1154
         4.File Comparisons:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1155
        </h2>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1156
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1157
      </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1158
     </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1159
     <p id="ch11Section_5_30">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1160
      Linux based distributions also have some utilities for checking the content of files, comparing them very quickly to other files. These operations can be looking for differences/similarities. Some of the commands which prove handy are:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1161
     </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1162
     <div class="section" title="4.1.cmp:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1163
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1164
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1165
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1166
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1167
          <a name="id2856693">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1168
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1169
          4.1.cmp:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1170
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1171
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1172
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1173
      </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1174
      <p id="ch11Section_5_31">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1175
       If one wants to compare two files whether they are same or not, one can use this handy tool. Let us consider some situation, we run find/locate command to locate some file, and it turns out that we have a file with same name in different location, and in case we want to run a quick check on there content, cmp is the right tool. For my system I perform these tasks to illustrate the use of this command:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1176
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1177
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1178
       $ find . -name quick.c
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1179
./Desktop/programs/quick.c
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1180
./c-folder/quick.c
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1181
$ cmp Desktop/programs/quick.c c-folder/quick.c
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1182
$
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1183
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1184
      <p id="ch11Section_5_32">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1185
       For me it returns nothing, hence that means both the files are exact copy of each other, by default, cmp is silent if the files are the same. Make some changes in one of the file and rerun the command. For me it works like this:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1186
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1187
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1188
       $ cmp Desktop/programs/quick.c c-folder/quick.c
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1189
Desktop/programs/quick.c c-folder/quick.c differ: byte 339, line 24
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1190
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1191
      <p id="ch11Section_5_33">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1192
       That is, if files differ, the byte and line number at which the first difference occurred is reported.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1193
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1194
     </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1195
     <div class="section" title="4.2.diff:">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1196
      <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1197
       <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1198
        <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1199
         <h3 class="title">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1200
          <a name="id2856735">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1201
          </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1202
          4.2.diff:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1203
         </h3>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1204
        </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1205
       </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1206
      </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1207
      <p id="ch11Section_5_34">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1208
       Now there are situations when one wants to exactly know the differences among two files, for them, GNU diff can show whether files are different without detailing the differences. For simple and basic usage of this programs, consider following example:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1209
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1210
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1211
       $ echo -e "quick nbrown nfox njumped nover nthe nlazy ndog" &gt; allcharacters.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1212
$ echo -e "quick nbrown nfox njmuped nover nteh nlzay ndog" &gt; problem.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1213
$ diff problem.txt allcharacters.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1214
4c4
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1215
&lt; jmuped
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1216
---
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1217
&gt; jumped
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1218
6,7c6,7
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1219
&lt; teh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1220
&lt; lzay
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1221
---
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1222
&gt; the
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1223
&gt; lazy
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1224
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1225
      <p id="ch11Section_5_35">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1226
       Looking at results above mentioned it is very trivial to deduce that, diff if used on two separate text files will result in line by line results for all the lines which are different. So most common use case scenario can be, got some files in various location of system with same name and size, just run diff through them and remove all the redundant files. Other similar command which one can find more effective for this can be
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1227
       <span class="emphasis">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1228
        <em>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1229
         sdiff
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1230
        </em>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1231
       </span>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1232
       , for the same files using sdiff will result in:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1233
      </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1234
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1235
       $ sdiff problem.txt allcharacters.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1236
quick                                                               quick
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1237
brown                                                               brown
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1238
fox                                                                 fox
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1239
jmuped                                                            | jumped
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1240
over                                                                over
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1241
teh                                                               | the
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1242
lzay                                                              | lazy
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1243
dog                                                                 dog
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1244
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1245
      <p id="ch11Section_5_36">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1246
       Some exercise for a change:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1247
      </p>
15
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1248
      <div class="itemizedlist">
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1249
       <ul class="itemizedlist" type="*">
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1250
        <li class="listitem" style="list-style-type: *">
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1251
         <p id="ch11Section_5_37">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1252
          Try using diff for any binary file, does it work?
15
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1253
         </p>
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1254
        </li>
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1255
        <li class="listitem" style="list-style-type: *">
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1256
         <p id="ch11Section_5_38">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1257
          What are other equivalent for diff command based on needs/requirements?
15
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1258
         </p>
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1259
        </li>
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1260
        <li class="listitem" style="list-style-type: *">
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1261
         <p id="ch11Section_5_39">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1262
          Can we use diff to compare two directories? If yes how?
15
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1263
         </p>
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1264
        </li>
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1265
       </ul>
f2383fee6584 Testing
amit@thunder
parents: 6
diff changeset
  1266
      </div>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1267
     </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1268
     <div class="section" title="4.3.comm:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1269
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1270
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1271
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1272
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1273
          <a name="id2856817">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1274
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1275
          4.3.comm:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1276
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1277
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1278
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1279
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1280
      <p id="ch11Section_5_3a">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1281
       This is one more command which proves handy at times, the short and sweet man page states "compare two sorted files line by line". Or this it compares sorted files and selects or rejects lines common to two files. For ex:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1282
      </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1283
      <pre class="programlisting">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1284
       $ sort allcharacters.txt&gt;sortedcharac.txt; sort problem.txt&gt;sortedprob.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1285
$ comm sortedcharac.txt sortedprob.txt
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1286
             brown
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1287
             dog
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1288
             fox
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1289
     jmuped
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1290
jumped
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1291
lazy
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1292
     lzay
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1293
             over
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1294
             quick
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1295
     teh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1296
the
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1297
      </pre>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1298
     </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1299
    </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1300
    <div class="section" title="5.Environment Variables:">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1301
     <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1302
      <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1303
       <div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1304
        <h2 class="title" style="clear: both">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1305
         <a name="id2856847">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1306
         </a>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1307
         5.Environment Variables:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1308
        </h2>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1309
       </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1310
      </div>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1311
     </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1312
     <p id="ch11Section_5_3b">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1313
      These variables like HOME, OSTYPE,Variables are a way of passing information from the shell to programs when you run them. Programs look "in the environment" for particular variables and if they are found will use the values stored. Standard UNIX variables are split into two categories, environment variables and shell variables. In broad terms, shell variables apply only to the current instance of the shell and are used to set short-term working conditions; environment variables have a farther reaching significance, and those set at login are valid for the duration of the session.By convention, environment variables have UPPER CASE and shell variables have lower case names.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1314
     </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1315
     <p id="ch11Section_5_3c">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1316
      Some of examples of Environment variables are(result may vary!):
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1317
     </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1318
     <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1319
      $ echo $OSTYPE
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1320
linux-gnu
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1321
$ echo $HOME
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1322
/home/baali
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1323
     </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1324
     <p id="ch11Section_5_3d">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1325
      To see all the variables and there values use any of following commands:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1326
     </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1327
     <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1328
      $ printenv | less
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1329
$ env
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1330
     </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1331
     <p id="ch11Section_5_3e">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1332
      The most commonly used environment variable is "PATH", it defines a list of directories to search through when looking for a command to execute. If you decide to put your own programs in a bin directory under your home directory, you'll have to modify the path to include that directory, or the system will never find your programs (unless you happen to be in that directory when you enter the command). Here's how to change your PATH variable so it includes your personal bin directory:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1333
     </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1334
     <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1335
      $ set PATH=$PATH:$HOME/bin
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1336
     </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1337
     <p id="ch11Section_5_3f">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1338
      See the difference in value of PATH variable before and after modifying it. One can also create its own variable to make things easier:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1339
     </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1340
     <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1341
      $ set repo = $HOME/Desktop/random/code
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1342
$ cd $repo
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1343
     </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1344
     <p id="ch11Section_5_40">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1345
      <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1346
       <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1347
        set
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1348
       </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1349
      </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1350
      command is used to define a variable for the current shell. Try opening a new shell and use the above mentioned command, it wont work as expected. The other child process wont be able to see these variables unless we
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1351
      <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1352
       <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1353
        export
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1354
       </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1355
      </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1356
      them. Repeat the above mentioned activity with
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1357
      <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1358
       <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1359
        export
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1360
       </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1361
      </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1362
      command. Now with all new shells,
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1363
      <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1364
       <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1365
        $repo
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1366
       </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1367
      </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1368
      will work.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1369
     </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1370
     <p id="ch11Section_5_41">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1371
      Again these changes are limited to current session. To make them permanent or get loaded each time you log in, just add those lines to
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1372
      <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1373
       <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1374
        .bashrc
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1375
       </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1376
      </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1377
      file.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1378
     </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1379
     <div class="section" title="5.1.Further Reading:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1380
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1381
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1382
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1383
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1384
          <a name="id2856946">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1385
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1386
          5.1.Further Reading:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1387
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1388
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1389
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1390
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1391
      <div class="itemizedlist">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1392
       <ul class="itemizedlist" type="*">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1393
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1394
         <p id="ch11Section_5_42">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1395
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1396
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1397
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1398
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1399
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1400
          http://lowfatlinux.com/linux-environment-variables.html
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1401
         </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1402
        </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1403
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1404
         <p id="ch11Section_5_43">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1405
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1406
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1407
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1408
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1409
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1410
          http://www.codecoffee.com/tipsforlinux/articles/030.html
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1411
         </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1412
        </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1413
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1414
         <p id="ch11Section_5_44">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1415
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1416
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1417
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1418
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1419
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1420
          http://www.ee.surrey.ac.uk/Teaching/Unix/unix8.html
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1421
         </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1422
        </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1423
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1424
         <p id="ch11Section_5_45">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1425
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1426
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1427
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1428
           <hr />
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1429
          </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1430
          http://en.wikipedia.org/wiki/Environment_variable
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1431
         </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1432
        </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1433
       </ul>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1434
      </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1435
     </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1436
    </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1437
    <div class="section" title="6.Shell Scripting:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1438
     <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1439
      <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1440
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1441
        <h2 class="title" style="clear: both">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1442
         <a name="id2857001">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1443
         </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1444
         6.Shell Scripting:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1445
        </h2>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1446
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1447
      </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1448
     </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1449
     <div class="section" title="6.1.Basics:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1450
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1451
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1452
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1453
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1454
          <a name="id2857009">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1455
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1456
          6.1.Basics:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1457
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1458
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1459
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1460
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1461
      <p id="ch11Section_5_46">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1462
       Shell program or shell script,a sequence of commands to a text file and tell the shell to execute the text file instead of entering the commands. The first
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1463
       <span class="emphasis">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1464
        <em>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1465
         "Hello World"
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1466
        </em>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1467
       </span>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1468
       sample for shell scripting is as easy as it sounds:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1469
      </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1470
      <pre class="programlisting">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1471
       $ echo '#!/bin/sh' &gt; my-script.sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1472
$ clear &gt;&gt; my-script.sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1473
$ echo 'echo Hello World' &gt;&gt; my-script.sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1474
$ chmod 755 my-script.sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1475
$ ./my-script.sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1476
Hello World
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1477
      </pre>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1478
      <p id="ch11Section_5_47">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1479
       The #! syntax(also known as shebang) is used in scripts to indicate an interpreter for execution under UNIX / Linux operating systems. The chmod is required to make the script executable. This script will just execute two commands,
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1480
       <span class="emphasis">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1481
        <em>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1482
         clear
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1483
        </em>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1484
       </span>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1485
       and
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1486
       <span class="emphasis">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1487
        <em>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1488
         echo
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1489
        </em>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1490
       </span>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1491
       one after another. One can also do the same task using a one liner command
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1492
       <span class="emphasis">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1493
        <em>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1494
         clear; echo 'Hello World';
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1495
        </em>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1496
       </span>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1497
       but as number of lines grows using a script file is helpful.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1498
      </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1499
      <p id="ch11Section_5_48">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1500
       So lets create a script which gives us all the filenames for given initial alphabet or string in a directory. Let the name of script be
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1501
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1502
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1503
         initial.sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1504
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1505
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1506
       , open it with text editor, and write:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1507
      </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1508
      <pre class="programlisting">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1509
       #!/bin/sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1510
ls &gt; temp
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1511
grep ^$1 &lt; temp
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1512
rm temp
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1513
$ chmod a+x initial.sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1514
$ ./initial.sh s
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1515
      </pre>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1516
      <p id="ch11Section_5_49">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1517
       The $1 in the script is pertaining to command line argument. All arguments passed via command line are accessed via
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1518
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1519
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1520
         $#
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1521
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1522
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1523
       with name of script being first member, that is $0. Now lets write a script for finding a file, and then checking when was it last modified:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1524
      </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1525
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1526
       #!/bin/sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1527
name=`find . -name $1 -print`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1528
echo $name
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1529
last_modified=`stat -c %y $name| cut -f 1 -d " "`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1530
echo "Last modified: $last_modified"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1531
$ ./search.sh fname
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1532
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1533
      <p id="ch11Section_5_4a">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1534
       Try giving some file you want to search in place of fname. Please note in second line
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1535
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1536
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1537
         `
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1538
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1539
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1540
       its a back-quote(other key mapped with tilda), it is specifically used to get the output of one command into a variable. In this particular case name is a User defined variables (UDV) which stores the value. We access value stored in any variable using
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1541
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1542
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1543
         $
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1544
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1545
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1546
       symbol before name of variable.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1547
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1548
      <p id="ch11Section_5_4b">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1549
       naming conventions for variables?? do we need them??
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1550
      </p>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1551
     </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1552
     <div class="section" title="6.2.Shell Arithmetic:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1553
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1554
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1555
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1556
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1557
          <a name="id2855367">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1558
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1559
          6.2.Shell Arithmetic:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1560
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1561
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1562
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1563
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1564
      <p id="ch11Section_5_4c">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1565
       Shell also provides support for basic arithmetic operations. The syntax is:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1566
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1567
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1568
       $ expr op1 math-operator op2
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1569
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1570
      <p id="ch11Section_5_4d">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1571
       Some of example which can be tried handily:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1572
      </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1573
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1574
       $ expr -3 + 5
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1575
2
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1576
$ expr 10 % 3
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1577
1
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1578
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1579
      <p id="ch11Section_5_4e">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1580
       These spaces in between operator and operands is important, without them shell interpreter will raise the syntax error.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1581
      </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1582
      <pre class="programlisting">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1583
       $ expr 2*3
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1584
expr: syntax error
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1585
      </pre>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1586
      <p id="ch11Section_5_4f">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1587
       One can use back-quotes(`) also to get value of expr.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1588
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1589
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1590
       $ echo `expr 6 + 3`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1591
9
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1592
$ result=`expr 6 + 3`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1593
$ echo $result
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1594
9
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1595
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1596
      <p id="ch11Section_5_50">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1597
       Shell uses three kinds of quotes. Double quotes("), anything enclosed among them except from variable trailing after $, and characters after would be printed as it is. Single quotes('), anything enclosed within them is just same, no formulation/interpretation. Back quotes(`), anything inclosed is considered as command, or is executed.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1598
      </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1599
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1600
       $ echo "Today is date"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1601
Today is date
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1602
$ echo "Today is `date`"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1603
Today is Wed Sep 16 17:32:22 IST 2009
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1604
$ echo 'Today is `date`'
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1605
Today is `date`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1606
$ echo "Today is  n `date`"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1607
Today is  n Wed Sep 16 17:40:13 IST 2009
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1608
$ echo -e "Today is  n `date`"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1609
Today is
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1610
 Wed Sep 16 17:41:13 IST 2009
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1611
      </pre>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1612
     </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1613
     <div class="section" title="6.3.if else construct:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1614
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1615
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1616
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1617
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1618
          <a name="id2857386">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1619
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1620
          6.3.if else construct:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1621
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1622
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1623
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1624
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1625
      <p id="ch11Section_5_51">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1626
       One can have simple
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1627
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1628
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1629
         if else if
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1630
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1631
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1632
       constructs in shell scripts to check conditions. Lets take simple example of writing a script which returns back whether the argument passed is positive or not:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1633
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1634
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1635
       #!/bin/sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1636
if test $1 -gt 0
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1637
then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1638
  echo "number is positive"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1639
else
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1640
  echo "number is negative"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1641
fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1642
$ ./sign.sh -11
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1643
number is negative
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1644
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1645
      <p id="ch11Section_5_52">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1646
       This script will compare the first value passed as argument with 0
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1647
       <span class="emphasis">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1648
        <em>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1649
         if test var -gt val
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1650
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1651
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1652
       , var being $1 and val being 0, gt meaning greater then. Now this program has some flaw, it will give same result for following input: (-11) and (-1, 5), as we are checking just $1 which is first argument and hence the result. For handling such situation we can include
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1653
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1654
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1655
         if-else
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1656
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1657
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1658
       clause which will warn user of correct usage of script.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1659
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1660
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1661
       #this is the case when no argument is passed
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1662
if [ $# -eq 0 ]
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1663
then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1664
  echo "$0 : You must give/supply one integers"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1665
  exit 1
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1666
else
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1667
  if [ $# -gt 1 ]
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1668
  then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1669
    echo "$0 : You must give one integer"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1670
    exit 1
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1671
  fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1672
fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1673
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1674
      <p id="ch11Section_5_53">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1675
       One important thing to not in shell script is spacing, with many comparison and evaluation operation a wrongly placed space will spoil all the fun. So in previous example the expression
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1676
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1677
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1678
         [ $# -eq 0 ]
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1679
        </em>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1680
       </span>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1681
       will work properly, but if we remove those leading or trailing spaces like
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1682
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1683
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1684
         [ $# -eq 0]
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1685
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1686
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1687
       , it wont work as expected, or rather throw a warning. Both
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1688
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1689
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1690
         test
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1691
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1692
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1693
       and
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1694
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1695
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1696
         []
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1697
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1698
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1699
       do the same task of testing a expression and returning true or false.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1700
      </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1701
      <p id="ch11Section_5_54">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1702
       Lets create something interesting using these if-else clause. Now we will create a script which will greet the user when he opens the shell. We will create the script, change the permission to make it executable and append the
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1703
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1704
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1705
         .bashrc
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1706
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1707
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1708
       file with
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1709
       <span class="emphasis">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1710
        <em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1711
         ./greet.sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1712
        </em>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1713
       </span>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1714
       line and we are done. The script is:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1715
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1716
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1717
       #!/bin/sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1718
#Script to greet the user according to time of day
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1719
temph=`date | cut -c12-13`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1720
dat=`date +"%A %d in %B of %Y (%r)"`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1721
if [ $temph -lt 12 ]
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1722
then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1723
  mess="Good Morning $LOGNAME, Have a nice day!"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1724
fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1725
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1726
if [ $temph -gt 12 -a $temph -le 16 ]
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1727
then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1728
  mess="Good Afternoon $LOGNAME"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1729
fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1730
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1731
if [ $temph -gt 16 -a $temph -le 18 ]
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1732
then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1733
  mess="Good Evening $LOGNAME"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1734
fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1735
echo -e "$mess nThis is $dat"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1736
      </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1737
      <p id="ch11Section_5_55">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1738
       For me when I open the shell the output is something like:
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1739
      </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1740
      <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1741
       Good Morning baali, Have a nice day!
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1742
This is Wednesday 16 in September of 2009 (11:54:47 AM IST)
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1743
      </pre>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1744
     </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1745
     <div class="section" title="6.4.Loops">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1746
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1747
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1748
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1749
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1750
          <a name="id2857492">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1751
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1752
          6.4.Loops
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1753
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1754
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1755
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1756
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1757
      <p id="ch11Section_5_56">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1758
       Bash has three different commands for looping --
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1759
       <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1760
        for
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1761
       </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1762
       ,
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1763
       <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1764
        while
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1765
       </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1766
       and
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1767
       <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1768
        until
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1769
       </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1770
       .
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1771
      </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1772
      <div class="section" title="6.4.1.for loop">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1773
       <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1774
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1775
         <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1776
          <h4 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1777
           <a name="id2857514">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1778
           </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1779
           6.4.1.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1780
           <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1781
            for
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1782
           </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1783
           loop
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1784
          </h4>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1785
         </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1786
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1787
       </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1788
       <p id="ch11Section_5_57">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1789
        Suppose we have a set of files, that have names beginning with numbers followed by their names -
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1790
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1791
         08 - Society.mp3
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1792
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1793
        . We would like to rename these files to remove the numbering. How would we go about doing that? It is clear from the problem statement that we could use a
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1794
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1795
         for
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1796
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1797
        loop, to loop through the list of files and rename each of the files.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1798
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1799
       <p id="ch11Section_5_58">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1800
        Let's first look at a simple
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1801
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1802
         for
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1803
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1804
        loop, to understand how it works.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1805
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1806
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1807
        for animal in rat cat dog man
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1808
do
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1809
  echo $animal
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1810
done
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1811
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1812
       <p id="ch11Section_5_59">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1813
        We just wrote a list of animals, each animal's name separated by a space and printed each name on a separate line. The variable
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1814
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1815
         animal
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1816
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1817
        is a dummy variable and has no significance. You could use something as lame as
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1818
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1819
         i
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1820
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1821
        in place of
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1822
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1823
         animal
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1824
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1825
        .
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1826
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1827
       <p id="ch11Section_5_5a">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1828
        Now, we use a simple
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1829
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1830
         for
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1831
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1832
        loop to list the files that we are interested in.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1833
       </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1834
       <pre class="programlisting">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1835
        ls *.mp3 &gt; list
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1836
for i in `cat list`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1837
do
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1838
  echo "$i"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1839
done
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1840
       </pre>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1841
       <p id="ch11Section_5_5b">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1842
        If your filenames contain spaces,
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1843
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1844
         for
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1845
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1846
        assumes each space separated word to be a single item in the list and prints it in a separate line. We could change the script slightly to overcome this problem.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1847
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1848
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1849
        for i in *.mp3
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1850
do
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1851
  echo "$i"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1852
done
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1853
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1854
       <p id="ch11Section_5_5c">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1855
        Now, we have each file printed on a separate line. Depending on the files that we have we could use grep to get the relevant portion of the filenames and rename the files.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1856
       </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1857
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1858
        for i in *.mp3
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1859
do
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1860
  j=$(echo "$i"|grep -o "[A-Za-z'&amp;. ]*.mp3")
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1861
  echo "$i -&gt; $j"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1862
done
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1863
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1864
       <p id="ch11Section_5_5d">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1865
        Now we just replace the echo command with a
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1866
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1867
         mv
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1868
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1869
        or a
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1870
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1871
         cp
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1872
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1873
        command.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1874
       </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1875
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1876
        for i in *.mp3
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1877
do
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1878
  j=$(echo "$i"|grep -o "[A-Za-z'&amp;. ]*.mp3")
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1879
  cp "$i" "$j"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1880
done
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1881
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1882
       <p id="ch11Section_5_5e">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1883
        As an exercise, you could try sorting the files in reverse alphabetical order and then prefix numbers to each of the filenames.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1884
       </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1885
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1886
      <div class="section" title="6.4.2.while">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1887
       <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1888
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1889
         <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1890
          <h4 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1891
           <a name="id2857633">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1892
           </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1893
           6.4.2.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1894
           <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1895
            while
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1896
           </code>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1897
          </h4>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1898
         </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1899
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1900
       </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1901
       <p id="ch11Section_5_5f">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1902
        The
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1903
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1904
         while
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1905
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1906
        command allows us to continuously execute a block of commands until the command that is controlling the loop is executing successfully.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1907
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1908
       <p id="ch11Section_5_60">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1909
        Let's start with the lamest example of a while loop.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1910
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1911
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1912
        while true
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1913
do
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1914
  echo "True"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1915
done
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1916
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1917
       <p id="ch11Section_5_61">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1918
        This, as you can see, is an infinite loop that prints the
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1919
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1920
         True
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1921
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1922
        .
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1923
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1924
       <p id="ch11Section_5_62">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1925
        Say we wish to write a simple program that takes user input and prints it back, until the input is
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1926
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1927
         quit
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1928
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1929
        , which quits the program.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1930
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1931
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1932
        while [ "$variable" != "quit" ]
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1933
do
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1934
  read variable
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1935
  echo "Input - $variable"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1936
done
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1937
exit 0
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1938
       </pre>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1939
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1940
      <div class="section" title="6.4.3.until">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1941
       <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1942
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1943
         <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1944
          <h4 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1945
           <a name="id2857683">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1946
           </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1947
           6.4.3.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1948
           <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1949
            until
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1950
           </code>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1951
          </h4>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1952
         </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1953
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1954
       </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1955
       <p id="ch11Section_5_63">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1956
        The
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1957
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1958
         until
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1959
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1960
        loop is similar to the
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1961
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1962
         while
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1963
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1964
        loop, except that it executes until the conditional command does not execute properly.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1965
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1966
       <p id="ch11Section_5_64">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1967
        The infinite loop changes to the following, when
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1968
        <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1969
         until
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1970
        </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1971
        is used.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1972
       </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1973
       <pre class="programlisting">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1974
        until false
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1975
do
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1976
  echo "True"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1977
done
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1978
       </pre>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1979
       <p id="ch11Section_5_65">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1980
        Now lets try and use these above mentioned options provided by shell to write a utility. Until now, when we try find or locate it looks through directories and files for result. But they wont search through tar archives and zipped files. Lets create a shell script for especially looking through these files
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1981
       </p>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  1982
       <pre class="programlisting">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1983
        #!/bin/sh
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1984
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1985
#To check number of arguments being passed.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1986
if [ $# -eq 0 ] ; then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1987
echo "Correct usage: $0 tar-archive filename  nOr $0 filename"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1988
exit 1
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1989
else
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1990
  if [ $# -eq 1 ] ; then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1991
    tar_archive=`find $PWD -name "*.tar*"`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1992
  else
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1993
    tar_archive=`find $PWD -name $1`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1994
  fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1995
fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1996
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1997
#Search of particular file inside archives.
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1998
for archive in $tar_archive
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  1999
do
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2000
  echo $archive
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2001
  variable=`tar -tf $archive`
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2002
  for word in $variable
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2003
  do
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2004
    if [ $# -eq 1 ] ; then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2005
      echo "$word" | grep -q ".*$1"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2006
    else
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2007
      echo "$word" | grep -q ".*$2"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2008
    fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2009
  if [ $? -eq 0 ] ; then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2010
    echo "File present in $archive!"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2011
  fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2012
  done
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2013
done
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2014
       </pre>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2015
      </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2016
     </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2017
     <div class="section" title="6.5.Functions">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2018
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2019
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2020
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2021
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2022
          <a name="id2857738">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2023
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2024
          6.5.Functions
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2025
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2026
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2027
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2028
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2029
      <p id="ch11Section_5_66">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2030
       When a group of commands are repeatedly being used within a script, it is convenient to group them as a function. This saves a lot of time and you can avoid retyping the code again and again. Also, it will help you maintain your code easily. Let's see how we can define a simple function,
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2031
       <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2032
        hello-world
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2033
       </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2034
       . Functions can be defined in bash, either using the
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2035
       <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2036
        function
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2037
       </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2038
       built-in followed by the function name or just the function name followed by a pair of parentheses.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2039
      </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2040
      <pre class="programlisting">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2041
       function hello-world
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2042
{
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2043
echo "Hello, World.";
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2044
}
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2045
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2046
hello-world () {
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2047
  echo "Hello, World.";
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2048
}
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2049
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2050
$ hello-world
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2051
Hello, World.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2052
      </pre>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2053
      <p id="ch11Section_5_67">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2054
       Passing parameters to functions is similar to passing them to scripts.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2055
      </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2056
      <pre class="programlisting">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2057
       function hello-name
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2058
{
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2059
echo "Hello, $1.";
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2060
}
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2061
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2062
$ hello-name 9
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2063
Hello, 9.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2064
      </pre>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2065
      <p id="ch11Section_5_68">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2066
       Any variables that you define within a function, will be added to the global namespace. If you wish to define variables that are restricted to the scope of the function, define a variable using the
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2067
       <code class="literal">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2068
        local
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2069
       </code>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2070
       built-in command of bash.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2071
      </p>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2072
      <p id="ch11Section_5_69">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2073
       We shall now write a function for the word frequency generating script that we had looked at in the previous session.
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2074
      </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2075
      <pre class="programlisting">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2076
       function word_frequency {
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2077
  if [ $# -ne 1 ]
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2078
  then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2079
    echo "Usage: $0 file_name"
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2080
    exit 1
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2081
  else
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2082
    if [ -f "$1" ]
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2083
    then
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2084
      grep  "[A-Za-z]*" -o "$1" | tr 'A-Z' 'a-z' | sort | uniq -c | sort -nr | less
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2085
    fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2086
  fi
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2087
}
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2088
      </pre>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2089
      <p id="ch11Section_5_6a">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2090
       As an exercise, modify the function to accept the input for the number of top frequency words to be shown (if none is given, assume 10).
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2091
      </p>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2092
     </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2093
     <div class="section" title="6.6.Further Reading:">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2094
      <div class="titlepage">
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2095
       <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2096
        <div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2097
         <h3 class="title">
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2098
          <a name="id2857809">
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2099
          </a>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2100
          6.6.Further Reading:
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2101
         </h3>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2102
        </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2103
       </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2104
      </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2105
      <div class="itemizedlist">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2106
       <ul class="itemizedlist" type="*">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2107
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2108
         <p id="ch11Section_5_6b">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2109
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2110
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2111
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2112
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2113
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2114
          http://www.freeos.com/guides/lsst/
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2115
         </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2116
        </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2117
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2118
         <p id="ch11Section_5_6c">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2119
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2120
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2121
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2122
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2123
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2124
          http://bash.cyberciti.biz/guide/Main_Page
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2125
         </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2126
        </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2127
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2128
         <p id="ch11Section_5_6d">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2129
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2130
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2131
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2132
           <hr />
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2133
          </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2134
          http://tldp.org/LDP/abs/html/
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2135
         </div>
25
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2136
        </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2137
        <li class="listitem" style="list-style-type: *">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2138
         <p id="ch11Section_5_6e">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2139
         </p>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2140
         <div class="reference">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2141
          <div class="titlepage">
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2142
           <hr />
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2143
          </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2144
          http://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2145
         </div>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2146
        </li>
ed38dd9bdb50 New build of html solving some of the bugs
amit@thunder
parents: 16
diff changeset
  2147
       </ul>
6
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2148
      </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2149
     </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2150
    </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2151
   </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2152
  </div>
1ce9b33fb6ff sorted the problem related to paths
amit@thunder
parents: 2
diff changeset
  2153
 </body>
1
672eaaab9204 Added some new html files that failed earlier during change from rst
amit@thunder
parents:
diff changeset
  2154
</html>