Your SlideShare is downloading. ×
0
The Bash Love
The Bash Love
The Bash Love
The Bash Love
The Bash Love
The Bash Love
The Bash Love
The Bash Love
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

The Bash Love

823

Published on

Presentation about Bash Scripting during MSCC (Mauritius Software Craftsmanship Community) meetup at University of Mauritiuds. 3 May 2014.

Presentation about Bash Scripting during MSCC (Mauritius Software Craftsmanship Community) meetup at University of Mauritiuds. 3 May 2014.

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

  • Be the first to like this

No Downloads
Views
Total Views
823
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
1
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. The Bash Love Ish Sookun Executive Member, Linux User Group of Mauritius Member, Mauritius Software Craftsmanship Community ishwon@openSUSE.org Ish Sookun The Bash Love May 2014 @ University of Mauritius
  • 2. Ish Sookun The Bash Love First things first A shell is a program that provides an interface to the operating system, which itself is an interface to the underlying hardware (^^,) ... A shell script is ridiculously just a bunch of commands. One may use arguments and variables coupled with logic control & a little bit of arithmetic to �gure out what and when to run. Popular shells are Bourne Shell (sh), Bourne Again Shell (bash), C Shell (csh), Korn Shell (ksh) ... You may Google the rest and have a moment of Shell history!
  • 3. Ish Sookun The Bash Love When to use Bash? Run a series of external commands Pipeline the output of one command as input to another Code something with only simple logic Develop incrementally Create tools to extend your command-line environment
  • 4. Ish Sookun The Bash Love Know your Coreutils Coreutils is a bunch of basic programs that run on Unix-like operating systems, doing file, shell and text manipulation. Most of these programs... do one thing & do it well work together handle text streams
  • 5. Ish Sookun The Bash Love Files & directories Everything Links Directories cp mv rm Copy files Move/rename files Delete files ln Make links mkdir rmdir Make directories Remove directories
  • 6. Ish Sookun The Bash Love Text Rows cat head tail sort uniq All rows First rows Last rows Sort rows Unique rows Fields cut paste join Subset fields Union fields (rows in order) Union fields (rows joined by a field)
  • 7. Ish Sookun The Bash Love Pipes & redirects Bash uses three standard I/O streams, each of which is associated with a well-known file descriptor: stdin having file descriptor 0 stdout having file descriptor 1 stderr having file descriptor 2 Examples: ps -ef | grep -i httpd ls -lRth > DirectoryContent.log mysql -u admin -p awesomeDB < awesomeDB_Backup.sql ./myScript.sh 2> error.log
  • 8. Ish Sookun The Bash Love Let's begin with Shebang Shebang, yes, that's how your Bash script starts. Oh! You don't write shebang but write #! instead. Read more about Shebang on Google. (^^,) #!/bin/bash # This is an innocent comment ME=`whoami` echo "You've gone nuts, $ME." chmod u+x myScript.sh By convention give your Bash scripts a .sh extension. You need to give execution right to your script before you're able to run it. Now, execute it at the terminal prompt as follows: ./myScript.sh

×