BASH/C2/Command-Line-arguments-and-Quoting/Gujarati

From Script | Spoken-Tutorial
Revision as of 12:14, 22 December 2014 by Jyotisolanki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Time Narration
00:01 Command line arguments and Quoting in BASH પરનાં આ સ્પોકન ટ્યુટોરીયલમાં સ્વાગત છે.
00:08 આ ટ્યુટોરીયલમાં, આપણે આપેલ વિશે શીખીશું,
00:11 * Command line Arguments અને
00:13 * Quoting
00:15 આ ટ્યુટોરીયલનાં અનુસરણ માટે તમે Linux Operating System થી પરિચિત હોવા જોઈએ
00:20 જો નથી, તો સંબંધિત ટ્યુટોરિયલ્સ માટે આપેલ અમારી વેબસાઈટની મુલાકાત લો.
00:26 આ ટ્યુટોરીયલ માટે, હું વાપરી રહ્યી છું,
00:29 * ઉબ્નટુ લીનક્સ 12.04 OS
00:33 * GNU Bash આવૃત્તિ 4.1.10
00:37 પ્રેક્ટીસ માટે GNU Bash આવૃત્તિ 4 અથવા તેથી વધુનો આગ્રહ કરીએ છીએ.
00:43 * Shell script આર્ગ્યુમેન્ટસ કમાંડ લાઈન થી સ્વીકારી શકાય છે.
00:46 * પ્રોગ્રામમાં પસાર કરેલ આર્ગ્યુમેન્ટને કોલ કરાય છે.
00:52 * એક પ્રોગ્રામમાં કેટલી પણ આર્ગ્યુમેન્ટસ પસાર કરી શકાય છે.
00:57 તમારા કીબોર્ડ પર Ctrl Alt અને T કી એક સાથે દાબીને ટર્મિનલ ખોલો.
01:06 મેં કોડ arg.sh નામની ફાઈલમાં પહેલાથી જ લખી દીધો છે.
01:12 ટર્મિનલ પર, ચાલો હું આ ફાઈલ ખોલું તે માટે ટાઈપ કરો.
01:16 gedit સ્પેસ arg.sh સ્પેસ ampersand ચિન્હ
01:23 આપણે એમ્પરસેન્ડનો ઉપયોગ પ્રોમ્પ્ટને સાફ કરવા માટે કરીએ છીએ.
01:27 હવે Enter. દબાઓ.
01:૩૦ ટેક્સ્ટ એડિટર ખુલે છે.
01:33 ચાલો હું અત્યારે કોડ સમજાઉ.
01:36 shenbang લાઈન છે.
01:39 આ લાઈન Zeroth આર્ગ્યુમેન્ટ પ્રિન્ટ કરશે.
01:43 અહી $0 (Dollar zero) શેલ સ્ક્રિપ્ટીંગનું નામ પ્રિન્ટ કરશે.
01:48 પરિણામ સ્વરૂપે આનો અર્થ એ છે કે, zeroth આર્ગ્યુમેન્ટ એ જાતે જ પ્રોગ્રામનું નામ છે.
01:55 ચાલો પ્રોગ્રામ એક્ઝીક્યુટ કરીને જોઈએ.
01:59 ટર્મિનલ પર જાવ.
02:01 સૌ પ્રથમ ફાઈલને એક્ઝિક્યુટેબલ બનાવો તે માટે ટાઈપ કરો,
02:05 chmod સ્પેસ plus x સ્પેસ arg.sh
02:12 Enter દબાઓ.
02:14 હવે ટાઈપ કરો dot slash arg.sh
02:18 Enter દબાઓ.
02:19 આઉટપુટ આપેલ પ્રમાણે દ્રશ્યમાન થાય છે: Zeroth argument is arg.sh
02:26 હવે આપણા એડિટર પર પાછા આવીએ અને અહી બતાવ્યા પ્રમાણે ત્રણ લાઈનો ટાઈપ કરીએ.
02:33 $1 (Dollar one) આ પહેલી આર્ગ્યુમેન્ટ રજુ કરે છે જે કમાંડ લાઈન પરથી પ્રોગ્રામમાં પસાર કરી છે.
02:40 $2 (Dollar two) પ્રોગ્રામમાં પસાર કરેલ બીજી આર્ગ્યુમેન્ટને રજુ કરે છે.
02:44 અને $3 (Dollar three) ત્રીજી આર્ગ્યુમેન્ટ રજુ કરે છે.
02:48 હવે Save પર ક્લિક કરો.
02:49 ચાલો પ્રોગ્રામ એક્ઝીક્યુટ કરીને જોઈએ.
02:52 ઉપરનું બાણ દર્શાવતી કીને દબાઓ Enter દબાઓ.
02:57 આપણે જોઈ શકીએ છીએ કે zeroeth આર્ગ્યુમેન્ટ પ્રિન્ટ થઇ છે.
03:00 પરંતુ પહેલી, બીજી અને ત્રીજી આર્ગ્યુમેન્ટસ ખાલી છે.
03:05 આ એટલા માટે કારણકે એક્ઝીક્યુટ પ્રક્રિયા દરમિયાન કમાંડ લાઈન આર્ગ્યુમેન્ટસ આપયી હતી.
03:11 તેથી અપએરો કી દબાઓ અને ટાઈપ કરો : sunday monday અને tuesday.
03:18 Enter દબાઓ
03:21 તમે જોઈ શકો છો કે પહેલી બીજી અને ત્રીજી આર્ગ્યુમેન્ટ આ Sunday Monday અને Tuesday છે.
03:28 હવે આપણા એડિટર પર પાછા જાવ Enter દબાઓ.
03:33 હવે અહી બતાવ્યા પ્રમાણે લાઈન ટાઈપ કરો.
03:37 $12 (Dollar twelve) twelveth આર્ગ્યુમેન્ટ રજુ કરે છે.
03:41 9, કરતા મોટી આર્ગ્યુમેન્ટસ લખવા માટે,આપણે છગડીયા કૌંસ વાપરવા પડે છે.
03:46 નહિતર બેશ ફક્ત દશાંશ સ્થાનના ઇનટીજરની આર્ગ્યુમેન્ટ લે શે.
03:53 અને તમને જોઈતું આઉટપુટ મળશે નહી.
03:57 હવે Save. પર ક્લિક કરો.
03:59 Let us execute the program. ચાલો પ્રોગ્રામ એક્ઝીક્યુટ કરીએ.
04:01 terminal. ટર્મિનલ પર જાઓ.
04:04 prompt. ચાલો હું પ્રોમ્પ્ટ સાફ કરું.
04:07 Now we need to give 12 or 13 arguments to the program.
04:12 Hence Type dot slash arg.sh space 1 to 13 Now press enter
04:23 You can see that the 12th argument is 12.
04:27 Come back to our editor.
04:30 And type the line as shown here.
04:34 $# (Dollar hash) gives the total number of arguments that have been passed to a program.
04:40 Now click on Save.
04:43 Let us execute.
04:44 Switch to the terminal.
04:46 Let us execute. Press the uparrow key and press Enter.
04:52 We can see that the total arguments are 13.
04:57 Now switch to the editor.
05:00 Press Enter and type the lines as shown here.
05:04 $* (Dollar asterix) will print all the arguments on a single line.
05:10 We will test this with the help of a simple for loop.
05:14 We will analyse this for loop at the time of execution.
05:18 Now click on Save.Switch to the terminal.
05:22 Let me clear the prompt.
05:26 Now let us type, dot slash arg.sh space sunday monday and tuesday
05:35 Press Enter
05:38 You can see that the total number of arguments are 3 as we have passed 3 arguments to our program.
05:46 As already said $* will print all the arguments on a single line.
05:54 And this is the output for the for loop.
05:57 We see that all the arguments are printed on the single line.
06:02 Now move back to our program and type the lines as shown here.
06:09 $@ (Dollar at) will also print all the arguments.
06:13 However, this time each argument will be printed on separate line.
06:20 This is another for loop, which will print each argument in a separate line.
06:26 Let us see how. Click on Save
06:29 Switch to the terminal.
06:32 Press the uparrow key.
06:34 Press Enter You can see the difference now.
06:39 These are the arguments printed by $@.
06:43 $@ prints each argument on separate line.
06:47 This is the output for the 2nd for loop.
06:52 Now lets move on to quoting in BASH
06:55 Switch to the slides.
06:57 There are three types of quotes
06:59 Double quote
07:00 Single quote
07:02 Backslash
07:03 * Double quote substitutes the value of variables and commands
07:09 * Example echo “Username is $USER”
07:13 * It displays your username of the system.
07:17 Switch to the Terminal.
07:20 Let me clear the prompt.
07:23 Now type echo space within double quotes Username space is dollar USER in capitals.
07:34 Press Enter
07:35 The username of the system is printed.
07:39 The output will vary according to your system.
07:42 Now move back to slides.
07:46 * Single quotes preserves the literal meaning of each character of the given string.
07:53 * It is used to turn off special meaning of all characters.
07:58 Switch to the Terminal.
08:01 Type echo space within single quote Username is dollar USER in capital
08:10 Press Enter
08:12 The output is Username is $USER
08:16 In this example, it prints all the characters which appear within the single quotes.
08:23 It does not substitute the value of variable $USER
08:28 Switch back to our slides.
08:31 * Backslash removes the special meaning from a single character
08:37 * It is used as an escape character in BASH
08:42 Switch to the Terminal.
08:44 Now Type echo space within double quote Username is backslash dollar USER (in capital)
08:55 Since we have given double quotes, we expect the echo command to display the username.
09:02 Let's try this command so press Enter.
09:06 The output is Username is $USER
09:10 In this example the backslash removes the special meaning of (Dollar) $ symbol.
09:16 $USER is just treated as a string without any special functionality.
09:22 This brings us to the end of this tutorial.
09:25 Switch back to our slides.
09:27 Let us summarize.
09:28 In this tutorial we learnt,
09:31 * Command line arguments
09:33 * Functionality of Double quote, Single quote and Backslash
09:39 Watch the video available at the link shown below
09:42 It summarises the Spoken Tutorial project
09:45 If you do not have good bandwidth, you can download and watch it
09:51 The Spoken Tutorial Project Team Conducts workshops using spoken tutorials
09:56 Gives certificates to those who pass an online test
10:00 For more details, please write to contact@spoken-tutorial.org
10:07 Spoken Tutorial Project is a part of the Talk to a Teacher project
10:10 It is supported by the National Mission on Education through ICT, MHRD, Government of India

More information on this Mission is available at: http://spoken-tutorial.org\NMEICT-Intro

10:24 The script has been contributed by FOSSEE and spoken-tutorial Team.
10:30 And this is Ashwini Patil from IIT Bombay signing off. Thank you for joining.

Contributors and Content Editors

Jyotisolanki, PoojaMoolya