SlideShare a Scribd company logo
Bash Script
Bash script
• Bash is a Unix shell written by Brian Fox for the GNU Project as a
free software replacement for the Bourne shell .
• Released in 1989,it has been distributed widely as the shell for
the GNU operating system and as a default shell on Linux and
Mac OS X.
Let’s explore Bash Script…
1.Variables
Bash script
Global vs. Local variables
2.Conditional statements and
loops
A.Conditional statements
If/else
Elif
Arithmetic Comparisons
Case
b.Loops
While
For(with numbers)
For(with directories)
For(with arrays)
Until
3.Bash functions
Syntax to create a bash function:
Function with arguments
Functions with returned values
4.String manipulations
a.String length
b.Substring extraction
c.Shortest Substring Match
d.Find and Replace String Values
e.Replace all the matches
f.Replace beginning and end
f.Replace beginning and end
5.I/O Redirection
a.Standard Output “>”
a.Standard Output “>”
b.Standard Input “<“
b.Standard Input “<“
c.Pipes “|”
Bash script
6.Special commands
a.Grep
• Is used to search a characters chain within a file
• -v displays the lines that do not contain the string
• -c count the number of lines containing the string
• -n each line containing the string is numbered
• -x the line that exactly matches the string
• -l displays the names of files that contain the string
Bash script
b.Find
• Is used to fined files based on specific criteria.
• Syntax: find <folder> <search criteria>
• -name search by name
• -perm search by access rihghts on file,
• -user search by file’s owner,
• -group search by file’s group,
Bash script
Bash script
Bash script
c.Awk
• Is used to print specific lines and columns from a file, with
conditions.
• Syntax : awk '{print $NF}' file
Bash script
Bash script
d.Sed
• The SED UNIX Command in Linux enables you to work with the
text inside your files and can be used to perform different
functions to it.
• Syntax :
Bash script
Bash script
e.Alias
• Is used to enable a replacement of a command by another
string
• Syntax : alias myalias=“command_name”
Thank you for your attention
Ad

Recommended

Example the aam
Example the aam
ThpHnhHNi
 
Informix health check - Brochure
Informix health check - Brochure
Vyasaka Technologies Pte Ltd
 
Quick start bash script
Quick start bash script
Simon Su
 
Unix Shell Scripting Basics
Unix Shell Scripting Basics
Dr.Ravi
 
Unix And Shell Scripting
Unix And Shell Scripting
Jaibeer Malik
 
Learning through play
Learning through play
Nurnabihah Mohamad Nizar
 
Corascent presentation4
Corascent presentation4
Mirra Aggarwal
 
Fronterdagkommunikation
Fronterdagkommunikation
Michael Bang
 
Linkedin
Linkedin
Bobby Munster
 
Octubre[1]
Octubre[1]
Anny pe?
 
Nursing
Nursing
ssalinas07
 
How to make_an_origami_crane
How to make_an_origami_crane
twistytwistlers1477
 
Black & Latino dominance on Twitter & Facebook, yet omission from Social Medi...
Black & Latino dominance on Twitter & Facebook, yet omission from Social Medi...
Golin
 
Science at kaiapoi high
Science at kaiapoi high
StPatricks
 
Ionut calugaru ocd_5_aprilie_2011
Ionut calugaru ocd_5_aprilie_2011
Ionuţ Călugăru
 
Things to do in the Digital Afterlife when you're dead
Things to do in the Digital Afterlife when you're dead
danbuzzo
 
進化ゲーム理論の枠組みを用いたソーシャルゲームにおけるユーザの利他的行動の分析
進化ゲーム理論の枠組みを用いたソーシャルゲームにおけるユーザの利他的行動の分析
Masanori Takano
 
Marhefka István - Clean Code - bookreview
Marhefka István - Clean Code - bookreview
Agile Hungary
 
Insp Butterfly
Insp Butterfly
DrRavi Jain
 
Disintegrated development in the rural urban fringe
Disintegrated development in the rural urban fringe
ruralfringe
 
論文紹介: What’s in a like- attitudes and behaviors around receiving likes on fac...
論文紹介: What’s in a like- attitudes and behaviors around receiving likes on fac...
Masanori Takano
 
3①本郷町内会 通信12月 テスト
3①本郷町内会 通信12月 テスト
hongochonaikai
 
Managing Growth on the Rural urban fringe
Managing Growth on the Rural urban fringe
ruralfringe
 
Razvoj i prezentacija na proekt
Razvoj i prezentacija na proekt
Cre8ive8
 
What SQL should actually be...
What SQL should actually be...
Open Academy
 
Unleash your inner console cowboy
Unleash your inner console cowboy
Kenneth Geisshirt
 
The Bash Love
The Bash Love
ishwon
 

More Related Content

Viewers also liked (20)

Fronterdagkommunikation
Fronterdagkommunikation
Michael Bang
 
Linkedin
Linkedin
Bobby Munster
 
Octubre[1]
Octubre[1]
Anny pe?
 
Nursing
Nursing
ssalinas07
 
How to make_an_origami_crane
How to make_an_origami_crane
twistytwistlers1477
 
Black & Latino dominance on Twitter & Facebook, yet omission from Social Medi...
Black & Latino dominance on Twitter & Facebook, yet omission from Social Medi...
Golin
 
Science at kaiapoi high
Science at kaiapoi high
StPatricks
 
Ionut calugaru ocd_5_aprilie_2011
Ionut calugaru ocd_5_aprilie_2011
Ionuţ Călugăru
 
Things to do in the Digital Afterlife when you're dead
Things to do in the Digital Afterlife when you're dead
danbuzzo
 
進化ゲーム理論の枠組みを用いたソーシャルゲームにおけるユーザの利他的行動の分析
進化ゲーム理論の枠組みを用いたソーシャルゲームにおけるユーザの利他的行動の分析
Masanori Takano
 
Marhefka István - Clean Code - bookreview
Marhefka István - Clean Code - bookreview
Agile Hungary
 
Insp Butterfly
Insp Butterfly
DrRavi Jain
 
Disintegrated development in the rural urban fringe
Disintegrated development in the rural urban fringe
ruralfringe
 
論文紹介: What’s in a like- attitudes and behaviors around receiving likes on fac...
論文紹介: What’s in a like- attitudes and behaviors around receiving likes on fac...
Masanori Takano
 
3①本郷町内会 通信12月 テスト
3①本郷町内会 通信12月 テスト
hongochonaikai
 
Managing Growth on the Rural urban fringe
Managing Growth on the Rural urban fringe
ruralfringe
 
Razvoj i prezentacija na proekt
Razvoj i prezentacija na proekt
Cre8ive8
 
What SQL should actually be...
What SQL should actually be...
Open Academy
 
Fronterdagkommunikation
Fronterdagkommunikation
Michael Bang
 
Octubre[1]
Octubre[1]
Anny pe?
 
Black & Latino dominance on Twitter & Facebook, yet omission from Social Medi...
Black & Latino dominance on Twitter & Facebook, yet omission from Social Medi...
Golin
 
Science at kaiapoi high
Science at kaiapoi high
StPatricks
 
Ionut calugaru ocd_5_aprilie_2011
Ionut calugaru ocd_5_aprilie_2011
Ionuţ Călugăru
 
Things to do in the Digital Afterlife when you're dead
Things to do in the Digital Afterlife when you're dead
danbuzzo
 
進化ゲーム理論の枠組みを用いたソーシャルゲームにおけるユーザの利他的行動の分析
進化ゲーム理論の枠組みを用いたソーシャルゲームにおけるユーザの利他的行動の分析
Masanori Takano
 
Marhefka István - Clean Code - bookreview
Marhefka István - Clean Code - bookreview
Agile Hungary
 
Disintegrated development in the rural urban fringe
Disintegrated development in the rural urban fringe
ruralfringe
 
論文紹介: What’s in a like- attitudes and behaviors around receiving likes on fac...
論文紹介: What’s in a like- attitudes and behaviors around receiving likes on fac...
Masanori Takano
 
3①本郷町内会 通信12月 テスト
3①本郷町内会 通信12月 テスト
hongochonaikai
 
Managing Growth on the Rural urban fringe
Managing Growth on the Rural urban fringe
ruralfringe
 
Razvoj i prezentacija na proekt
Razvoj i prezentacija na proekt
Cre8ive8
 
What SQL should actually be...
What SQL should actually be...
Open Academy
 

Similar to Bash script (8)

Unleash your inner console cowboy
Unleash your inner console cowboy
Kenneth Geisshirt
 
The Bash Love
The Bash Love
ishwon
 
BASH Guide Summary
BASH Guide Summary
Ohgyun Ahn
 
Bash shell
Bash shell
xylas121
 
Unit 4 scripting and the shell
Unit 4 scripting and the shell
Bhushan Pawar -Java Trainer
 
Scripting and the shell in LINUX
Scripting and the shell in LINUX
Bhushan Pawar -Java Trainer
 
Licão 02 shell basics bash intro
Licão 02 shell basics bash intro
Acácio Oliveira
 
Exploitation Crash Course
Exploitation Crash Course
UTD Computer Security Group
 
Ad

Bash script