summaryrefslogtreecommitdiff
path: root/ult/ult_6/script.rst
blob: 020f3a677a8e98afe6073cc3d43f6689b05889a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
.. Objectives
.. ----------
   
   .. At the end of this tutorial, you will be able to:
   
   ..   1. Understand various features of shell
   ..   2. Learn about shell meta characters

.. Prerequisites
.. -------------

..   1. Getting started with Linux
..   2. Basic File Handling
..   4. Advanced file handling
 
Script
------

.. L1

{{{ Show the  first slide containing title, name of the production
team along with the logo of MHRD }}}

.. R1

Hello friends and Welcome to the tutorial on 
'Redirection and Piping'.

.. L2

{{{ Show slide with objectives }}} 

.. R2

At the end of this tutorial, you will be able to,

 1. Understand various features of shell
 #. Learn about shell meta characters

.. L3

{{{ Switch to the pre-requisite slide }}}

.. R3

Before beginning this tutorial,we would suggest you to complete the 
former tutorials as being displayed currently.

.. L4

{{{ Show slide, with Tab-completion }}} 

.. R4

The Bash shell has some nice features, that make our job of using the shell 
easier and much more pleasant. We shall look at a few of them, here.


Bash provides the feature of tab completion. What does tab completion mean? 
When you are trying to type a word, bash can complete the word for you, if you 
have entered enough portion of the word (to complete it unambiguously) and 
then hit the tab key.

If on hitting the tab key, the word doesn't get completed, either the word 
doesn't exist or the word cannot be decided unambiguously. If the case is the 
latter one, hitting the tab key a second time, will list the possibilities.

.. L5

{{{ Show slide, with Tab-completion.. }}} 

.. R5

Bash provides tab completion for the following.

        File Names
        Directory Names
        Executable Names
        User Names (when they are prefixed with a ~)
        Host Names (when they are prefixed with a @)
        Variable Names (when they are prefixed with a $)

.. R6

For example,

.. L6

{{{ Switch to terminal }}}
::


    pas<TAB><TAB>
    PA<TAB>
    ~/<TAB><TAB>

.. L7

{{{ Show slide, with History }}}

.. R7

Bash also saves the history of the commands you have typed. So, you can go 
back to a previously typed command. Use the up and down arrow keys to navigate 
in your bash history.
You can also search incrementally, for commands in your bash history. Ctrl-r 
search for the commands that you have typed before. But, note that the number 
of commands saved in the history is limited, generally upto a 1000 commands.

.. L8

{{{ Switch to terminal }}}
::

    <Ctrl-r> pas

.. R8

.. L9

{{{ Show slide, with Shell Meta Characters }}} 

.. R9

Unix recognizes certain special characters, called "meta characters," as 
command directives. The shell meta characters are recognized anywhere they 
appear in the command line, even if they are not surrounded by blank space. 
For that reason, it is safest to only use the characters A-Z, a-z, 0-9, and 
the period, dash, and underscore characters when naming files and directories
 on Unix. If your file or directory has a shell meta character in the name, 
you will find it difficult to use the name in a shell command.

The characters that you see on the slide are the shell meta characters

 / < > ! $ % ^ & * | { } [ ] " ' ` ~ ;

.. R10

Let's take an example,

.. L10

{{{ Switch to terminal }}} 
::

    ls file.*

.. R11

It means, run on a directory containing the files file, file.c, file.lst, and 
myfile would list the files file.c and file.lst. However,

.. L11

::

    ls file.?

.. R12

Run on the same directory would only list file.c because the ? only 
matches  one character, no more, no less. This can save you a great deal of 
typing time.

For example, if there is a file called california_cornish_hens_with_wild_rice 
and no other files whose names begin with 'c', you could view the file without 
typing the whole name by typing this

.. L12

::

    more c*

.. R13

Here, the c* matches that long file name.

File-names containing metacharacters can pose many problems and should never 
be intentionally created.

.. L13

.. L14

{{{ Switch to Summary slide }}}

.. R14

This brings us to the end of the end of this tutorial.
In this tutorial, we have learnt to,

1. Implement features of tab-completion and history.
#. Make use of the shell meta characters.
 
.. L15
 
{{{ Show self assessment questions slide }}}

.. R15

Here are some self assessment questions for you to solve:

1. Bash does not provide tab completion for Host Names. True of False?

2. State the command which will list all the files in the current working 
   directory that end in either .c or .h

.. L16

{{{ Solutions for the self assessment questions on slide }}}

.. R16

And the answers:

1. False. Bash provides tab completion for Host Names when they are prefixed 
   with a @ sign.

  
2. The command which will find the files ending either in .c or .h is,
::

    ls *.[ch]


.. L17

{{{ Show the SDES & FOSSEE slide }}}

.. R17

Software Development techniques for Engineers and Scientists - SDES, is an 
initiative by FOSSEE. For more information, please visit the given link.

Free and Open-source Software for Science and Engineering Education - FOSSEE, is
based at IIT Bombay which is funded by MHRD as part of National Mission on 
Education through ICT.

.. L18

{{{ Show the ``About the Spoken Tutorial Project'' slide }}}

.. R18

Watch the video available at the following link. It summarises the Spoken 
Tutorial project.If you do not have good bandwidth, you can download and 
watch it. 

.. L19

{{{ Show the `` Spoken Tutorial Workshops'' slide }}}

.. R19

The Spoken Tutorial Project Team conducts workshops using spoken tutorials,
gives certificates to those who pass an online test.

For more details, contact contact@spoken-tutorial.org

.. L20

{{{ Show the ``Acknowledgements'' slide }}}

.. R20

Spoken Tutorial Project is a part of the "Talk to a Teacher" project.
It is supported by the National Mission on Education through ICT, MHRD, 
Government of India. More information on this mission is available at the 
given link.

.. L21

{{{ Show the Thank you slide }}}

.. R21

Hope you have enjoyed this tutorial and found it useful.
Thank you!