BASH/C3/More-on-Redirection/Gujarati

From Script | Spoken-Tutorial
Revision as of 11:26, 9 February 2015 by Jyotisolanki (Talk | contribs)

Jump to: navigation, search
Timee Narration
00:01 નમસ્તે મિત્રો More on redirection પરનાં સ્પોકન ટ્યુટોરીયલમાં સ્વાગત છે.
00:07 આ ટ્યુટોરીયલમાં, આપણે શીખીશું standard error અને output બંનેનું રીડાયરેક્શન
00:13 રીડાઈ રેક્ટ કરેલ આઉટપુટ ઉમેરવા.
00:15 ઉમુક ઉદાહરણ સાથે સમજીએ.
00:19 આ ટ્યુટોરીયલનાં અનુસરણ માટે તમને બેશમાંનાં Shell Scripting નું જ્ઞાન હોવું અનિવાર્ય છે.
00:25 જો નથી, તો સંદર્ભિત ટ્યુટોરીયલો માટે કૃપા કરી દર્શાવેલ અમારી વેબસાઈટનો સંદર્ભ લો, http://www.spoken-tutorial.org
00:30 આ ટ્યુટોરીયલ માટે હું વાપરી રહી છું. ઉબુન્ટુ લીનક્સ 12.04 ઓપરેટીંગ સીસ્ટમ અને
00:35 GNU BASH આવૃત્તિ 4.2
00:39 કૃપા કરી નોંધ લો, આ ટ્યુટોરીયલનાં અભ્યાસ માટે GNU Bash આવૃત્તિ 4 કે તેથી વધુ આગ્રહ કરીએ છીએ.
00:46 અગાઉના ટ્યુટોરીયલમાં આપણે શીખ્યા standard output અને standard errors .
00:52 stderr તેમજ stdout બંનેને એકજ ફાઈલમાં રીડાઈ રેક્ટ કરી શકાય છે.
00:58 આ ઘણી રીતે કરી શકાય છે.
01:01 આપણે આ ટ્યુટોરીયલમાં મહત્વના બે રીડાયરેક્શન મેથડો આવરી આવરી લેશું.
01:08 પ્રથમ મેથડમાં &> અને ગ્રેટર ધેન ચિન્હ વાપરીએ બંને standard output અને error ને રીડાઈ રેક્ટ કરવું છે.
01:18 સિન્ટેક્સ છે Command space ampersand greater than space filename
01:25 ચાલો હું redirect.sh. નામક ફાઈલ ખોલું.
01:30 મેં આ ફાઈલમાં અમુક કોડ ટાઈપ કર્યા છે.
01:32 shebang line. છે.
01:36 ls/usr અને /user નામની બે ડિરેક્ટરીમાની વિષયવસ્તુ દેખાડે છે.
01:44 નોંધલો /user એ ડિરેક્ટરી અસ્તિત્વમાં નથી.
01:48 એટલા માટે ls કમાંડ એરર આપશે.
01:52 &(ampersand) અને આગળ greater than ચિન્હstdout અને stderr to out_(underscore)file.txt પર રીડાઈ રેક્ટ કરશે.
02:03 હવે ફાઈલ સેવ કરો.
02:05 redirect.sh. ફાઈલ રન કરો.
02:07 તમારા કીબોર્ડ પર એકસાથે CTRL+ALT+T keys દાબીને ટર્મિનલ ખોલો.
02:15 ટાઈપ કરો chmod space plus x space redirect dot sh
02:23 Enter દબાઓ.
02:25 ટાઈપ કરો dot slash redirect dot sh
02:28 Enter દબાઓ.
02:30 out_(underscore)file.(dot)txt ખોલીને આપણે આઉટપુટ જોઈ શકીએ છીએ.
02:36 ટાઈપ કરો cat space out_(underscore)file.(dot)txt
02:42 આપણે error અને output. બંને જોઈ શકીએ છીએ.
02:48 આ ફાઈલમાં /user આ ડિરેક્ટરી માટેની એરર નોંધાઈ છે.
02:51 It says that there was no '/user' directory found.
02:56 The directory content for /usr is displayed.
03:00 Please note that the content for '/usr' directory may vary on your system.
03:06 Now let us delete this file. So, on the terminal Type rm space out_(underscore)file. (dot)txt
03:15 Another method is to use 2 greater than ampersand 1 after the filename
03:24 The syntax is command space greater than filename space 2 greater than ampersand 1
03:33 We can also redirect to slash dev slash null (/dev/null) file.
03:39 Let us learn a little more about slash dev slash null (/dev/null) file.
03:45 It is a special kind of file
03:48 It is a null file or a place where we can dump anything.
03:52 It includes the output and error messages
03:57 It is also called as bit bucket.
04:00 Let us now come back to our code in gedit.
04:04 Let us redirect both standard output and error to the null file.
04:11 I will copy this line of code and paste it below over here.
04:16 I want both the output and error messages to be discarded.
04:21 So I will change this part of the copied code.> (greater than) means truncate or write.
04:30 slash dev slash null is the null file 2>&1 (2 greater than ampersand 1)
04:37 Number “2” will redirect standard error to standard output, denoted by number “1”.
04:45 Now click on Save. Save the code.
04:48 Let us run the file redirect.sh.
04:52 Go to the terminal.
04:54 Recall the previous command with the up-arrow key. dot slash redirect.sh and press Enter.
05:03 We can see the output by typing cat out_(underscore)file.(dot)txt
05:11 Come back to our slides.
05:15 * We can capture as well as append standard output or error to a file.
05:21 The output or the error will be appended at the end of the file.
05:26 If the file does not exist, it will create a new file.
05:31 The syntax is command space greater than greater than space followed by filename
05:41 Let us understand this using an example.
05:45 Let me open the file redirect.(dot)sh
05:49 Now, here let's Type date space greater than greater than space out_(underscore)file.(dot)txt
06:00 The 'date' command will simply display the system date as output.
06:06 We can check this command on the terminal by typing 'date.'
06:11 Come back to the terminal.Type date You can see that the system date i.e. the current date is displayed.
06:23 The output of date command will be appended to the out_(underscore)file.(dot)txt file.
06:31 We are using this file to capture standard output and error of ls command.
06:39 Click on Save
06:40 Switch to the terminal.
06:43 Now press the uparrow key.Recall the previous command dot slash redirect dot sh
06:50 and press Enter.
06:52 Let us check the output by opening out_(underscore) file.(dot)txt
06:59 Type cat space out_(underscore)file.(dot)txt
07:05 Observe that the output of 'date' command is appended to the end of the file.
07:12 This brings us to the end of this tutorial.
07:15 Let us summarise.
07:17 In this tutorial we learnt
07:19 Redirection of both standard error and output And to append the redirected output
07:27 As an assignment,
07:29 Create X_(underscore)file.(dot)txt file with some content.
07:34 Redirect the content of both out_(underscore)file.(dot)txt and X_(underscore)file.(dot)txt to a new file.
07:44 Watch the video available at the link shown below.
07:47 It summarises the Spoken Tutorial project.
07:51 If you do not have good bandwidth, you can download and watch it.
07:56 The Spoken Tutorial Project Team Conducts workshops using spoken tutorials Gives certificates to those who pass an online test
08:06 For more details, please write to contact@spoken-tutorial.org
08:13 Spoken Tutorial Project is a part of the Talk to a Teacher project.
08:17 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

08:30 The script has been contributed by FOSSEE and Spoken-Tutorial teams.
08:37 This is Ashwini from IIT Bombay.Thank you for joining.

Contributors and Content Editors

Jyotisolanki, PoojaMoolya