SlideShare une entreprise Scribd logo
1  sur  53
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
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 “|”
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
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,
c.Awk
• Is used to print specific lines and columns from a file, with
conditions.
• Syntax : awk '{print $NF}' file
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 :
e.Alias
• Is used to enable a replacement of a command by
another string
• Syntax : alias myalias=“command_name”
Thank you for your attention

Contenu connexe

En vedette (20)

Marketing de biblioteca
Marketing de bibliotecaMarketing de biblioteca
Marketing de biblioteca
 
Building your developer resume
Building your developer resumeBuilding your developer resume
Building your developer resume
 
老师的启示
老师的启示老师的启示
老师的启示
 
FAS 20 mei: Gauke Pieter Sietzema over MODX
FAS 20 mei: Gauke Pieter Sietzema over MODXFAS 20 mei: Gauke Pieter Sietzema over MODX
FAS 20 mei: Gauke Pieter Sietzema over MODX
 
Laura
LauraLaura
Laura
 
Miguel
MiguelMiguel
Miguel
 
Magvas gondolatok
Magvas gondolatokMagvas gondolatok
Magvas gondolatok
 
2國際物流績效
2國際物流績效2國際物流績效
2國際物流績效
 
Cables alambricos e inalambricos
Cables alambricos e inalambricosCables alambricos e inalambricos
Cables alambricos e inalambricos
 
Incremental Costs of Voucher Scheme - Chrispus Mayora
Incremental Costs of Voucher Scheme - Chrispus MayoraIncremental Costs of Voucher Scheme - Chrispus Mayora
Incremental Costs of Voucher Scheme - Chrispus Mayora
 
SugarCRM - What's New in Version 7.7
SugarCRM - What's New in Version 7.7SugarCRM - What's New in Version 7.7
SugarCRM - What's New in Version 7.7
 
Article Review
Article ReviewArticle Review
Article Review
 
Libros que leemos este año
Libros que leemos este añoLibros que leemos este año
Libros que leemos este año
 
Folhas anatomia
Folhas   anatomiaFolhas   anatomia
Folhas anatomia
 
Technology Trends Social Media June 2011
Technology Trends Social Media June 2011Technology Trends Social Media June 2011
Technology Trends Social Media June 2011
 
Javier arana
Javier aranaJavier arana
Javier arana
 
Eucaristia - repartir unir
Eucaristia - repartir unirEucaristia - repartir unir
Eucaristia - repartir unir
 
4 g
4 g4 g
4 g
 
Email Marketing May 2011
Email Marketing May 2011Email Marketing May 2011
Email Marketing May 2011
 
Printer
PrinterPrinter
Printer
 

Similaire à Bash script final

Similaire à Bash script final (8)

Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
The Bash Love
The Bash LoveThe Bash Love
The Bash Love
 
BASH Guide Summary
BASH Guide SummaryBASH Guide Summary
BASH Guide Summary
 
Bash shell
Bash shellBash shell
Bash shell
 
Unit 4 scripting and the shell
Unit 4 scripting and the shellUnit 4 scripting and the shell
Unit 4 scripting and the shell
 
Scripting and the shell in LINUX
Scripting and the shell in LINUXScripting and the shell in LINUX
Scripting and the shell in LINUX
 
Licão 02 shell basics bash intro
Licão 02 shell basics bash introLicão 02 shell basics bash intro
Licão 02 shell basics bash intro
 
Exploitation Crash Course
Exploitation Crash CourseExploitation Crash Course
Exploitation Crash Course
 

Bash script final