Your SlideShare is downloading. ×
0
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-navi-mumbai

65

Published on

shell-scripting-course-provider-navi-mumbai-shell-scripting-classes-navi-mumbai-shell-scripting-training-navi-mumbai-best-shell-scripting-classes-navi-mumbai …

shell-scripting-course-provider-navi-mumbai-shell-scripting-classes-navi-mumbai-shell-scripting-training-navi-mumbai-best-shell-scripting-classes-navi-mumbai
B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
enquiry@vibrantgroup.co.in

Published in: Education, Technology, Travel
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
65
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Vibrant Technologies & Computers Shell scripting COURSE Make Career With Us!! B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
  • 2. shellscriptingtraining.vibranttechnologies.co.in Why Shell? • The commercial UNIX used Korn Shell • For Linux, the Bash is the default • Why Shell? – For routing jobs, such as system administration, without writing programs – However, the shell script is not efficient, therefore, can be used for prototyping the ideas • For example, % ls –al | more (better format of listing directory) % man bash | col –b | lpr (print man page of man) B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in
  • 3. shellscriptingtraining.vibranttechnologies.co.in What is Shell? • Shell is the interface between end user and the Linux system, similar to the commands in Windows • Bash is installed as in /bin/sh • Check the version % /bin/sh --version B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in
  • 4. shellscriptingtraining.vibranttechnologies.co.in Pipe and Redirection • Redirection (< or >) % ls –l > lsoutput.txt (save output to lsoutput.txt) % ps >> lsoutput.txt (append to lsoutput.txt) % more < killout.txt (use killout.txt as parameter to more) % kill -l 1234 > killouterr.txt 2 >&1 (redirect to the same file) % kill -l 1234 >/dev/null 2 >&1 (ignore std output) • Pipe (|) – % % % Process are executed concurrently ps | sort | more ps –xo comm | sort | uniq | grep –v sh | more cat mydata.txt | sort | uniq | > mydata.txt (generates an empty file !) B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in
  • 5. shellscriptingtraining.vibranttechnologies.co.in Writing a Script • Use text editor to generate the “first” file #!/bin/sh # first # this file looks for the files containing POSIX # and print it for file in * do if grep –q POSIX $file then echo $file fi done exit 0 % /bin/sh first % chmod +x first %./first (make sure . is include in PATH parameter) B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in
  • 6. shellscriptingtraining.vibranttechnologies.co.in Syntax • • • • • • • • Variables Conditions Control Lists Functions Shell Commands Result Document B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in
  • 7. shellscriptingtraining.vibranttechnologies.co.in Environment Variables • • • • • • • • $HOME $PATH $PS1 $PS2 $$ $# $0 $IFS home directory path 第一層提示符號 (normally %) 第二層提示符號 (normally >) process id of the script number of input parameters name of the script file separation character (white space) • Use „env‟ to check the value B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in
  • 8. shellscriptingtraining.vibranttechnologies.co.in Loop Structure • Use wildcard „*‟ #!/bin/sh for file in $(ls f*.sh); do lpr $file done exit 0 Print all f*.sh files B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in
  • 9. shellscriptingtraining.vibranttechnologies.co.in Regular Expressions • Search for lines ending with “e” % grep e$ words2.txt • Search for “a” % grep a[[:blank:]] word2.txt • Search for words starting with “Th.” % grep Th.[[:blank:]] words2.txt • Search for lines with 10 lower case characters % grep –E [a-z]{10} words2.txt B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in
  • 10. shellscriptingtraining.vibranttechnologies.co.in Command • $(command) to execute command in a script • Old format used “`” but it can be confused with “‟” #!/bin/sh echo The current directory is $PWD echo the current users are $(who) B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in
  • 11. shellscriptingtraining.vibranttechnologies.co.in Arithmetic Expansion • Use $((…)) instead of expr to evaluate arithmetic equation #!/bin/sh x=0 while [ “$x” –ne 10]; do echo $x x=$(($x+1)) done exit 0 B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in
  • 12. shellscriptingtraining.vibranttechnologies.co.in Debug • sh –n<script> set -o noexec check syntax set –n • sh –v<script> set -o verbose echo command before set –v • sh –x<script> set –o trace echo command after set –x set –o nounset gives error if undefined set –x set –o xtrace set +o xtrace trap „echo Exiting: critical variable =$critical_variable‟ EXIT B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in
  • 13. shellscriptingtraining.vibranttechnologies.co.in Where to Get More Information Vibrant Group: www.vibrantgroup.co.in Vibrant Technologies & Computers www.vibranttechnologies.co.in/technologies.vibrantgroup.co. in Vibrant HR Team www.hr.vibrangroup.co.in B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 shellscriptingtraining.vibranttechnologies.co.in enquiry@vibrantgroup.co.in

×