BASH/C2/Arithmetic-Comparison/Gujarati

From Script | Spoken-Tutorial
Revision as of 16:47, 2 January 2015 by Jyotisolanki (Talk | contribs)

Jump to: navigation, search

Title of script: Arithmetic comparison in BASH

Author: Jyoti Solanki Keywords: video tutorial, Bash shell, -eq, -ne, -gt, -ge, -lt, -le


Time Narration
00:01 બેશમાં 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 * પ્રથમ cat કમાંડએ ફાઈલ વાંચશે.
01:53 આ ઈનપુટ ફાઈલ છે.
01:55 * આ પછી wc' કમાંડ પાસે પાઈપ કરેલ અથવા મોકલાશે.
02:00 * તો આ સ્ટેટમેંટ આપેલ ફાઈલમાં શબ્દ ગણશે.
02:05 * આઉટપુટ વેરીએબલ x. માં સંગ્રહિત છે.
02:08 if statement છે.
02:10 - (hyphen) eq આ કમાંડ શબ્દની સંખ્યા ઝીરો છે કે તે તપાસશે.
02:16 જો કન્ડીશન true, હશે તો “File has zero words”. મેસેજ પ્રિન્ટ થશે.
02:22 fi થી પ્રથમ if કન્ડીશનનો અંત થશે.
02:26 અહી બીજું એક if કન્ડીશન છે.
02:28 અહી , - (hyphen) ne કમાંડ શબ્દ સંખ્યા એ ઝીરો નથી તે તપાસશે.
02:35 જો કન્ડીશન true, હોય તો “File has so-and-so words” પ્રિન્ટ કરશે.
02:40 $ (dollar) x શબ્દ સંખ્યા બતાડશે.
02:43 અહી બીજી ઇફ કન્ડીશનનો અંત થાય છે.
02:46 તમારી પ્રોગ્રામ ફાઈલ સેવ કરો.
02:48 ચાલો આપણો પ્રોગ્રામ એક્ઝીક્યુટ કરીએ.
02:51 terminal. ટર્મિનલ ખોલો.
02:53 પથમ ચાલો list.txt ફાઈલ બનાવો.
02:57 ટાઈપ કરો: touch list.txt
03:01 ચાલો,ફાઈલમાં લાઈન ઉમેરો.
03:04 Type:

echo બે અવતરણચિહ્નોમાં “How are you” બે અવતરણચિહ્નો પછી greater than ચિન્હ list.txt

03:13 ચાલો આપણી ફાઈલ એક્ઝિક્યુટેબલ બનાવીએ.
03:16 Type:

chmod plus x example1 dot sh

03:21 હવે ટાઈપ કરો dot slash example1.sh
03:26 Enter filename દ્રશ્યમાન છે.
03:28 Type:

list.txt

03:31 આઉટપુટ : list.txt has 3 words તરીકે દેખાશે.
03:36 ચાલો હવે બીજા ઓપરેટર્સ વિષે શીખીએ.
03:40 હું બજી ફાઈલ તરફે જઈશ.
03:43 આ 'example2.sh છે.
03:46 તમારા એડિટર પર ફાઈલ ખોલો અને 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
  • - (hyphen) ge command checks whether word count is greater than or equal to one
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,
  • equal to
  • not equal to
  • less than
  • less than equal to
  • greater than and
  • greater than equal to commands
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.

Contributors and Content Editors

Jyotisolanki, PoojaMoolya