BASH/C2/Arithmetic-Comparison/Gujarati
From Script | Spoken-Tutorial
Revision as of 13:09, 2 January 2015 by Jyotisolanki (Talk | contribs)
Title of script: Arithmetic comparison in BASH
Author: Ashwini Patil
Keywords: video tutorial, Bash shell, -eq, -ne, -gt, -ge, -lt, -le
| Time | Narration |
|---|---|
| 00:01 | Welcome to the spoken tutorial onબેશમાં Arithmetic Comparison પરનાં આ સ્પોકન ટ્યુટોરીયલમાં સ્વાગત છે. |
| 00:07 | આ ટ્યુટોરીયલમાં, આપણે આપેલ વિશે શીખીશું, |
| 00:09 | * equal to |
| 00:10 | not equal to |
| 00:12 | less than |
| 00:13 | less than equal to |
| 00:15 | greater than અને |
| 00:16 | greater than equal to commands |
| 00:19 | આપણે આ અમુક ઉદાહરણના મદદથી કરીશું. |
| 00:23 | આ ટ્યુટોરીયલ માટે, હું વાપરી રહ્યી છું, |
| 00:26 | *ઉબ્નટુ લીનક્સ 12.04 ઓપરેટીંગ સિસ્ટમ અને |
| 00:30 | *GNU BASH આવૃત્તિ 4.1.10 |
| 00:34 | નોંધ લો પ્રેક્ટીસ માટે GNU Bash આવૃત્તિ 4 અથવા તેથી વધુનો આગ્રહ કરીએ છીએ. |
| 00:39 | arithmetic operators ના કેટલક ઉદાહરણો આપણી પસે છે. |
| 00:43 | ચાલો તે જોઈએ. |
| 00:45 | મેં ફાઈલને example1.sh નામ આપ્યું છે. |
| 00:50 | આ ફાઈલને તમારી પસંદગી મુજબના એડિટરમાં ખોલો અને દેખાડેલ કોડ ટાઈપ કરો. |
| 00:56 | આ કેવી રીતે કરવું તે તમને હમણાં શુધી ખબર પડી ગયી હશે. |
| 01:00 | આ પ્રોગ્રામમાં ફાઈલ ખાલી છે કે નહી તે તપાસવાના કરીશું. |
| 01:06 | ચાલો હું કોડ સમજાવું. |
| 01:08 | આ shebang line છે. |
| 01:10 | પ્રથમ કન્સોલ પર “Enter filename” પ્રિન્ટ થશે. |
| 01:15 | command reads one line of data from the standard input. પાસેથી મળેલ ડેટાને read કમાંડ વાંચશે. |
| 01:20 | આ કમાંડ backticks. છે. |
| 01:24 | Backtick વિશિષ્ઠ અર્થ ધરાવે છે. |
| 01:27 | backtick માં ટાઈપ કરેલ બધુજ મૂલ્યાંકન થાય છે. |
| 01:32 | cat કમાંડ ફાઈલમાં વિષયવસ્તુ દર્શાવશે. |
| 01:37 | wc પ્રત્યેક ફાઈલમાટે નવી લાઈન પર શબ્દ, અને બાઈટ ગણતરી પ્રિન્ટ કરશે. |
| 01:43 | - (hyphen) w શબ્દ ગણતરી પ્રિન્ટ કરશે. |
| 01:47 | શું થશે - |
| 01:49 | * First the cat command will read the file. |
| 01:53 | This is the input file. |
| 01:55 | * Which is then piped or sent to the wc command. |
| 02:00 | * So, this statement counts the words in a given file. |
| 02:05 | * The output is stored in variable x. |
| 02:08 | This is the if statement |
| 02:10 | - (hyphen) eq command checks whether word count is equal to zero. |
| 02:16 | If the condition is true, we will print a message “File has zero words”. |
| 02:22 | fi is the end of first if condition. |
| 02:26 | Here is another if condition. |
| 02:28 | Here, - (hyphen) ne command checks whether word count is not equal to zero. |
| 02:35 | If the condition is true, we print “File has so-and-so words”. |
| 02:40 | $ (dollar) x will give the word count. |
| 02:43 | This is the end of 2nd if condition. |
| 02:46 | Save your program file. |
| 02:48 | let us execute our program. |
| 02:51 | Open the terminal. |
| 02:53 | First let's create a file list.txt |
| 02:57 | Type: touch list.txt |
| 03:01 | Now, let's add a line in the file. |
| 03:04 | Type:
echo within double quotes “How are you” after the double quotes greater than sign list.txt |
| 03:13 | Now let's make our script executable. |
| 03:16 | Type:
chmod plus x example1 dot sh |
| 03:21 | Now type dot slash example1.sh |
| 03:26 | Enter filename is displayed. |
| 03:28 | Type:
list.txt |
| 03:31 | The output is displayed as: list.txt has 3 words |
| 03:36 | Now let's learn about another set of operators. |
| 03:40 | Let me switch to another file. |
| 03:43 | This is example2.sh . |
| 03:46 | Please open a file in your editor and name it as example2.sh |
| 03:52 | Now type the code as shown here in your example2.sh file. |
| 03:58 | Let me explain the code. |
| 04:00 | This program will check whether the word count is |
| 04:04 | * greater or less than one |
| 04:07 | * Between one and hundred Or above hundred. |
| 04:11 | We have our shebang line here. |
| 04:14 | read statement takes input as filename from the user. |
| 04:19 | Here, - (hyphen) c command is used to print the byte counts. |
| 04:24 | In the if statement, - (hyphen) lt command checks whether word count is less than one. |
| 04:31 | If the condition is true, then we print “No characters present in the file”. |
| 04:37 | fi ends the if condition. |
| 04:40 | The next if statement contains a nested if statement. |
| 04:45 | First the - (hyphen) gt command checks whether word count is greater than one. |
| 04:51 | If yes, then this echo statement will be executed. |
| 04:56 | There are multiple conditions within this if statement. |
| 05:01 | Here, in this if
|
| 05:09 | * and - (hyphen) le command checks whether word count is less than or equal to hundred. |
| 05:17 | If both the conditions are satisfied, then it prints: |
| 05:21 | Number of characters ranges between 1 and 100. |
| 05:25 | Please note that both conditions should be true to satisfy the entire if condition. |
| 05:33 | This is because we have included ampersand in-between both the conditions. |
| 05:39 | fi is the end of this if statement. |
| 05:43 | Then the next if statement will be evaluated. |
| 05:47 | - (hyphen) gt command checks whether word count is greater than hundred. |
| 05:53 | If the condition is satisfied, we print Number of characters is above hundred. |
| 06:00 | fi is the end of if statement. |
| 06:04 | Here we end the 2nd if statement. |
| 06:07 | Now come back to our terminal. |
| 06:10 | Let us execute the program. |
| 06:13 | chmod plus x example2 dot sh |
| 06:18 | dot slash example2 dot sh |
| 06:22 | Type list.txt |
| 06:25 | The output is displayed as list.txt has more than one character. |
| 06:31 | Number of characters ranges between one and hundred |
| 06:36 | Now, add or remove characters to the list.txt file. |
| 06:40 | Then observe which if statement gets executed. |
| 06:46 | This brings us to the end of this tutorial. |
| 06:49 | Let us summarize. |
| 06:51 | In this tutorial we learnt,
|
| 07:03 | As an assignment, write a program to demonstrate the use of not equal to operator. |
| 07:09 | Hint: - (hyphen) ne |
| 07:12 | Watch the video available at the link shown below |
| 07:15 | It summarises the Spoken Tutorial project |
| 07:18 | If you do not have good bandwidth, you can download and watch it |
| 07:23 | The Spoken Tutorial Project Team |
| 07:25 | Conducts workshops using spoken tutorials |
| 07:28 | Gives certificates to those who pass an online test |
| 07:32 | For more details, please write to contact@spoken-tutorial.org |
| 07:40 | Spoken Tutorial Project is a part of the Talk to a Teacher project |
| 07:43 | It is supported by the National Mission on Education through ICT, MHRD, Government of India |
| 07:51 | More information on this Mission is available at the link shown below. |
| 07:56 | The script has been contributed by FOSSEE and spoken-tutorial team. |
| 08:02 | This is Ashwini Patil from IIT Bombay signing off. |
| 08:06 | Thank you for joining. |