Example: air traffic controller

Linux Shell Scripting Tutorial v2

PDF generated using the open source mwlib toolkit. See for more generated at: Mon, 31 May 2010 07:27:26 CETL inux Shell Scripting by Vivek Gite Edited By Various ContributorsContentsArticlesLinux Shell Scripting Tutorial - A Beginner's handbook:About1 Chapter 1: Quick Introduction to Linux4 What Is Linux4 Who created Linux5 Where can I download Linux6 How do I Install Linux6 Linux usage in everyday life7 What is Linux Kernel7 What is Linux Shell8 Unix philosophy11 But how do you use the shell12 What is a Shell Script or Shell scripting13 Why Shell scripting14 Chapter 1 Challenges16 Chapter 2: Getting Started With Shell Programming17 The bash shell17 Shell commands19 The role of shells in the Linux environment21 Other standard shells23 Hello, World!

Linux system administrators or students who have mastered the basics of a Linux Operating System. You should be able to: • Login to local or remote Linux system. • Use basic Linux commands, such as cp, mv, rm, man,less, chmod and others. • Create and edit text files in vi or any other text editor.

Tags:

  Linux, Basics, Tutorials, Basic linux

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Linux Shell Scripting Tutorial v2

1 PDF generated using the open source mwlib toolkit. See for more generated at: Mon, 31 May 2010 07:27:26 CETL inux Shell Scripting by Vivek Gite Edited By Various ContributorsContentsArticlesLinux Shell Scripting Tutorial - A Beginner's handbook:About1 Chapter 1: Quick Introduction to Linux4 What Is Linux4 Who created Linux5 Where can I download Linux6 How do I Install Linux6 Linux usage in everyday life7 What is Linux Kernel7 What is Linux Shell8 Unix philosophy11 But how do you use the shell12 What is a Shell Script or Shell scripting13 Why Shell scripting14 Chapter 1 Challenges16 Chapter 2: Getting Started With Shell Programming17 The bash shell17 Shell commands19 The role of shells in the Linux environment21 Other standard shells23 Hello, World!

2 Tutorial25 Shebang27 Shell Comments29 Setting up permissions on a script30 Execute a script31 Debug a script32 Chapter 2 Challenges33 Chapter 3:The Shell Variables and Environment34 Variables in shell34 Assign values to Shell variables38 Default Shell variables value40 Rules for Naming variable name41 Display the value of Shell variables42 Quoting46 The export statement49 Unset Shell and environment variables50 Getting User Input Via Keyboard50 Perform arithmetic operations54 Create an integer variable56 Create the constants variable57 Bash variable existence check58 Customize the bash Shell environments59 Recalling command history63 Path name expansion65 Create and use aliases67 The tilde expansion69 Startup scripts70 Using aliases72 Changing bash prompt73

3 Setting Shell options77 Setting system wide Shell options82 Chapter 3 Challenges83 Chapter 4: Conditionals Execution (Decision Making)84 Bash structured language constructs84 Test command86If structures to execute code based on a condition87If..else..fi89 Nested ifs92 Multilevel if- then- else93 The exit status of a command94 Conditional execution97 Logical AND &&97 Logical OR ||98 Logical Not !99 Conditional expression using [101 Conditional expression using <nowiki>[[</ nowiki>102 Numeric comparison102 String comparison104 File attributes comparisons105 Shell command line parameters110 How to use positional parameters112 Parameters Set by the Shell114 Create usage messages115 Exit command117 The case statement119 Dealing with case sensitive pattern123 Chapter 4 Challenges126 Chapter 5: Bash Loops127 The for loop statement127 Nested for loop statement133 The while loop statement135 Use of.]]]

4 To set infinite while loop139 The until loop statement141 The select loop statement143 Exit the select loop statement146 Using the break statement148 Using the continue statement150 Command substitution153 Chapter 5 Challenges155 Chapter 6: Shell Redirection157 Input and Output157 Standard input158 Standard output159 Standard error160 Empty file creation161/ dev/ null discards unwanted output162 Here documents164 Here strings166 Redirection of standard error167 Redirection of standard output169 Appending redirected output170 Redirection of both standard error and output170 Writing output to files171 Assigns the file descriptor (fd) to file for output173 Assigns the file descriptor (fd) to file for input174 Closes the file descriptor (fd)175 Opening the file descriptors for reading and writing175 Reads from the file descriptor (fd)

5 176 Executes commands and send output to the file descriptor (fd)179 Chapter 6 Challenges185 Chapter 7: Pipes and Filters186 Linking Commands186 Multiple commands187 Putting jobs in background188 Pipes190 How to use pipes to connect programs191 Input redirection in pipes193 Output redirection in pipes194 Why use pipes194 Filters195 Chapter 7 Challenges197 Chapter 8: Traps198 Signals198 What is a Process?199 How to view Processes201 Sending signal to Processes204 Terminating Processes206 Shell signal values209 The trap statement210 How to clear trap212 Include trap statements in a script214 Use the trap statement to catch signals and handle errors216 What is a Subshell?

6 220 Compound command222 Exec command223 Chapter 8 Challenges224 Chapter 9: Functions225 Writing your first Shell function225 Displaying functions226 Removing functions228 Defining functions228 Writing functions231 Calling functions232 Pass arguments into a function237 Local variable240 Returning from a function243 Shell functions library245 Source command248 Recursive function249 Putting functions in background251 Chapter 9 Challenges253 Chapter 10: Interactive Scripts254 Menu driven scripts254 Getting information about your system256 Bash display dialog boxes260 Dialog customization with configuration file263A yes/ no dialog box267An input dialog box268A password box270A menu box273A progress bar (gauge box)

7 276 The form dialog for input279 Console management281 Get the name of the current terminal282 Fixing the display with reset283 Get screen width and hight with tput284 Moving the cursor with tput284 Display centered text in the screen in reverse video285 Set the keyboard leds286 Turn on or off NumLock leds286 Turn on or off CapsLock leds287 Turn on or off ScrollLock leds287/etc288 Shell Scripting help288 Recommended Books288 ReferencesArticle Sources and Contributors289 Image Sources, Licenses and Contributors293 Article LicensesLicense294 Linux Shell Scripting Tutorial - A Beginner's handbook:About1 Linux Shell Scripting Tutorial - A Beginner'shandbook:AboutThis document is Copyright (C) 1999-2009 by Vivek Gite [1] and its contributors.

8 Some rights book is for students and Linux System Administrators. It provides the skills to read, write, and debug Linuxshell scripts using bash Shell . The book begins by describing Linux and simple scripts to automate frequentlyexecuted commands and continues by describing conditional logic, user interaction, loops, menus, traps, andfunctions. Finally, book covers various sys admin related scripts such as making a backup, using cron jobs, writinginteractive tools, web based tools, remote login, ftp and database backup related scripts. This book is intended forLinux system administrators or students who have mastered the basics of a Linux Operating System.

9 You should beable to: Login to local or remote Linux system. Use basic Linux commands, such as cp, mv, rm, man,less, chmod and others. Create and edit text files in vi or any other text editor. GUI is not required except for interactive GTK+ based GUI InformationThis book is available under Creative Commons Attribution-Noncommercial-Share Alike Unported [2]. You are free: to Share to copy, distribute and transmit the work to Remix to adapt the work Under the following conditions: Attribution If you republish this content, we require that that the content is from " Linux Shell Scripting Tutorial - A Beginner's handbook" (http:/ / biz/ guide/ Main_Page), and nixCraft (http:/ / nixcraft.)

10 Com/ ). to the original article on the source site ( , http:/ / bash. cyberciti. biz/ guide/ What_Is_Linux) the author name ( , Vivek Gite) for all each contributors name back to their profile page on the source wiki ( , http:/ / bash. cyberciti. biz/guide/ User:USERNAME) Noncommercial You may not use this work for commercial purposes including the Internet ad supportedwebsites or any sort of print media. Share Alike If you alter, transform, or build upon this work, you may distribute the resulting work only underthe same or similar license to this the understanding that: Waiver Any of the above conditions can be waived if you get permission from the copyright holder ( theAuthor: Vivek Gite).


Related search queries