SlideShare a Scribd company logo
www.techvilla.org.in
TECHVILLA
www.techvilla.org.in
www.techvilla.org.in
Working with the Shell
 What is shell?
 Different shells in linux.
 Programming in shell.
 Shell vs windows cmd
www.techvilla.org.in
What’s Shell?
 It’s acts an interface between the user and OS (kernel).It’s known as “ command
interpreter”.
 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)
www.techvilla.org.in
Shell basics
 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
Kernel
Other
programs
X window
bash
csh
www.techvilla.org.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 !)
www.techvilla.org.in
Shell as a Language
 We can write a script containing many shell commands
 Interactive Program:
 grep files with POSIX string and print it
% for file in *
> do
> if grep –l POSIX $file
> then
> more $file
 fi
 done
Posix
There is a file with POSIX in it
 ‘*’ is wildcard
% more `grep –l POSIX *`
% more $(grep –l POSIX *)
% more –l POSIX * | more
www.techvilla.org.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)
www.techvilla.org.in
Syntax
 Variables
 Conditions
 Control
 Lists
 Functions
 Shell Commands
 Result
 Document
www.techvilla.org.in
Variables
 Variables needed to be declared, note it is case-sensitive (e.g. foo, FOO, Foo)
 Add ‘$’ for storing values
% salutation=Hello
% echo $salutation
Hello
% salutation=7+5
% echo $salutation
7+5
% salutation=“yes dear”
% echo $salutation
yes dear
% read salutation
Hola!
% echo $salutation
Hola!
www.techvilla.org.in
Quoting
 Edit a “vartest.sh” file
#!/bin/sh
myvar=“Hi there”
echo $myvar
echo “$myvar”
echo `$myvar`
echo $myvar
echo Enter some text
read myvar
echo ‘$myvar’ now equals $myvar
exit 0
Output
Hi there
Hi there
$myvar
$myvar
Enter some text
Hello world
$myvar now equals Hello world
www.techvilla.org.in
Environment Variables
 $HOME home directory
 $PATH path
 $PS1 第一層提示符號 (normally %)
 $PS2 第二層提示符號 (normally >)
 $$ process id of the script
 $# number of input parameters
 $0 name of the script file
 $IFS separation character (white space)
 Use ‘env’ to check the value
www.techvilla.org.in
Shell vs windows cmd
 The difference of Windows and Linux
 Case sensitive in Linux
 / in Linux
 No relationship between executable file and extension
 don't search current path
 Security policy is more strict in Linux
 link file VS shortcut

More Related Content

What's hot

OpenGurukul : Language : Shell Scripting
OpenGurukul : Language : Shell ScriptingOpenGurukul : Language : Shell Scripting
OpenGurukul : Language : Shell Scripting
Open Gurukul
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsSudharsan S
 
BASH Guide Summary
BASH Guide SummaryBASH Guide Summary
BASH Guide SummaryOhgyun Ahn
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Zyxware Technologies
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Geeks Anonymes
 
Shell programming 1.ppt
Shell programming  1.pptShell programming  1.ppt
Shell programming 1.ppt
Kalkey
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
Jaibeer Malik
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Manav Prasad
 
Unix shell scripting
Unix shell scriptingUnix shell scripting
Unix shell scripting
Pavan Devarakonda
 
Bash shell
Bash shellBash shell
Bash shellxylas121
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
Chandan Kumar Rana
 
system management -shell programming by gaurav raikar
system management -shell programming by gaurav raikarsystem management -shell programming by gaurav raikar
system management -shell programming by gaurav raikar
GauravRaikar3
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsDr.Ravi
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
Amit Ghosh
 
Scripting 101
Scripting 101Scripting 101
Scripting 101
ohardebol
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
Narendra Sisodiya
 

What's hot (20)

OpenGurukul : Language : Shell Scripting
OpenGurukul : Language : Shell ScriptingOpenGurukul : Language : Shell Scripting
OpenGurukul : Language : Shell Scripting
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
BASH Guide Summary
BASH Guide SummaryBASH Guide Summary
BASH Guide Summary
 
Chap06
Chap06Chap06
Chap06
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Shell programming 1.ppt
Shell programming  1.pptShell programming  1.ppt
Shell programming 1.ppt
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Unix shell scripting
Unix shell scriptingUnix shell scripting
Unix shell scripting
 
Bash shell
Bash shellBash shell
Bash shell
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
Unix - Shell Scripts
Unix - Shell ScriptsUnix - Shell Scripts
Unix - Shell Scripts
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
system management -shell programming by gaurav raikar
system management -shell programming by gaurav raikarsystem management -shell programming by gaurav raikar
system management -shell programming by gaurav raikar
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
 
Scripting 101
Scripting 101Scripting 101
Scripting 101
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
 

Viewers also liked

Self determined learning: Creating personal learning environments for lifelon...
Self determined learning: Creating personal learning environments for lifelon...Self determined learning: Creating personal learning environments for lifelon...
Self determined learning: Creating personal learning environments for lifelon...
Lisa Blaschke
 
Barista sponsorship
Barista sponsorshipBarista sponsorship
Barista sponsorship
Jatin Ghritlahre
 
Volunteer Consultants for Women's Building in San Francisco
Volunteer Consultants for Women's Building in San FranciscoVolunteer Consultants for Women's Building in San Francisco
Volunteer Consultants for Women's Building in San Francisco
Chung-Ying Yeh
 
Sistema de redes de seguridad CSS
Sistema de redes de seguridad CSSSistema de redes de seguridad CSS
Sistema de redes de seguridad CSSMichael Castillo
 
Apresentação
ApresentaçãoApresentação
Apresentação
Lívia Fabrin Pereira
 
รายชื่อผู้มีสิทธิ์สอบสัมภาษณ์ สกอ.
รายชื่อผู้มีสิทธิ์สอบสัมภาษณ์ สกอ.รายชื่อผู้มีสิทธิ์สอบสัมภาษณ์ สกอ.
รายชื่อผู้มีสิทธิ์สอบสัมภาษณ์ สกอ.
Took Bandasak
 
Californication tv show
Californication tv showCalifornication tv show
Californication tv show
tvshows100
 
Assignment 35 final
Assignment 35 final Assignment 35 final
Assignment 35 final
benchaisty
 
OER Roadmap (OE Global Pre-conference workshop)
OER Roadmap (OE Global Pre-conference workshop)OER Roadmap (OE Global Pre-conference workshop)
OER Roadmap (OE Global Pre-conference workshop)
The Open Education Consortium
 
Daftar nama peserta uas paai 2013
Daftar nama peserta uas paai 2013Daftar nama peserta uas paai 2013
Daftar nama peserta uas paai 2013Vendi Supendi
 
Domain game
Domain gameDomain game

Viewers also liked (20)

Self determined learning: Creating personal learning environments for lifelon...
Self determined learning: Creating personal learning environments for lifelon...Self determined learning: Creating personal learning environments for lifelon...
Self determined learning: Creating personal learning environments for lifelon...
 
Barista sponsorship
Barista sponsorshipBarista sponsorship
Barista sponsorship
 
CARTILHA CNJ.PDF
CARTILHA  CNJ.PDFCARTILHA  CNJ.PDF
CARTILHA CNJ.PDF
 
Tarjeta
TarjetaTarjeta
Tarjeta
 
Volunteer Consultants for Women's Building in San Francisco
Volunteer Consultants for Women's Building in San FranciscoVolunteer Consultants for Women's Building in San Francisco
Volunteer Consultants for Women's Building in San Francisco
 
Sistema de redes de seguridad CSS
Sistema de redes de seguridad CSSSistema de redes de seguridad CSS
Sistema de redes de seguridad CSS
 
Apresentação
ApresentaçãoApresentação
Apresentação
 
Un bello corazón
Un bello corazónUn bello corazón
Un bello corazón
 
Fotos
FotosFotos
Fotos
 
Familia
FamiliaFamilia
Familia
 
Reptiles de san san 2010
Reptiles de san san 2010 Reptiles de san san 2010
Reptiles de san san 2010
 
รายชื่อผู้มีสิทธิ์สอบสัมภาษณ์ สกอ.
รายชื่อผู้มีสิทธิ์สอบสัมภาษณ์ สกอ.รายชื่อผู้มีสิทธิ์สอบสัมภาษณ์ สกอ.
รายชื่อผู้มีสิทธิ์สอบสัมภาษณ์ สกอ.
 
Quest Radio Station
Quest Radio StationQuest Radio Station
Quest Radio Station
 
Californication tv show
Californication tv showCalifornication tv show
Californication tv show
 
Expectativas e Ilusões
Expectativas e IlusõesExpectativas e Ilusões
Expectativas e Ilusões
 
NatalyaResume2015
NatalyaResume2015NatalyaResume2015
NatalyaResume2015
 
Assignment 35 final
Assignment 35 final Assignment 35 final
Assignment 35 final
 
OER Roadmap (OE Global Pre-conference workshop)
OER Roadmap (OE Global Pre-conference workshop)OER Roadmap (OE Global Pre-conference workshop)
OER Roadmap (OE Global Pre-conference workshop)
 
Daftar nama peserta uas paai 2013
Daftar nama peserta uas paai 2013Daftar nama peserta uas paai 2013
Daftar nama peserta uas paai 2013
 
Domain game
Domain gameDomain game
Domain game
 

Similar to Raspberry pi Part 4

Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25
Techvilla
 
Best training-in-mumbai-shell scripting
Best training-in-mumbai-shell scriptingBest training-in-mumbai-shell scripting
Best training-in-mumbai-shell scripting
vibrantuser
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administration
vceder
 
Bash shell programming in linux
Bash shell programming in linuxBash shell programming in linux
Bash shell programming in linuxNorberto Angulo
 
2-introduction_to_shell_scripting
2-introduction_to_shell_scripting2-introduction_to_shell_scripting
2-introduction_to_shell_scriptingerbipulkumar
 
60761 linux
60761 linux60761 linux
60761 linux
Ritika Ahlawat
 
UnixShells.ppt
UnixShells.pptUnixShells.ppt
UnixShells.ppt
EduardoGutierrez111076
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
SHARANBAJWA
 
Best training-in-mumbai-shell scripting
Best training-in-mumbai-shell scriptingBest training-in-mumbai-shell scripting
Best training-in-mumbai-shell scripting
vibrantuser
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
sudhir singh yadav
 
Shell_Scripting.ppt
Shell_Scripting.pptShell_Scripting.ppt
Shell_Scripting.ppt
KiranMantri
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
Tushar Jain
 
Linux Basics
Linux BasicsLinux Basics
Linux Basics
Team-VLSI-ITMU
 
Linux command for beginners
Linux command for beginnersLinux command for beginners
Linux command for beginners
SuKyeong Jang
 
Php mysql
Php mysqlPhp mysql
Php mysql
Ajit Yadav
 
Using Unix
Using UnixUsing Unix
Using UnixDr.Ravi
 
2023comp90024_linux.pdf
2023comp90024_linux.pdf2023comp90024_linux.pdf
2023comp90024_linux.pdf
LevLafayette1
 
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEAShell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Thuy_Dang
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
kavitha_tala
 

Similar to Raspberry pi Part 4 (20)

Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25
 
Best training-in-mumbai-shell scripting
Best training-in-mumbai-shell scriptingBest training-in-mumbai-shell scripting
Best training-in-mumbai-shell scripting
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administration
 
Bash shell programming in linux
Bash shell programming in linuxBash shell programming in linux
Bash shell programming in linux
 
2-introduction_to_shell_scripting
2-introduction_to_shell_scripting2-introduction_to_shell_scripting
2-introduction_to_shell_scripting
 
60761 linux
60761 linux60761 linux
60761 linux
 
UnixShells.ppt
UnixShells.pptUnixShells.ppt
UnixShells.ppt
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Best training-in-mumbai-shell scripting
Best training-in-mumbai-shell scriptingBest training-in-mumbai-shell scripting
Best training-in-mumbai-shell scripting
 
Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Shell_Scripting.ppt
Shell_Scripting.pptShell_Scripting.ppt
Shell_Scripting.ppt
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 
Linux Basics
Linux BasicsLinux Basics
Linux Basics
 
Linux command for beginners
Linux command for beginnersLinux command for beginners
Linux command for beginners
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Using Unix
Using UnixUsing Unix
Using Unix
 
2023comp90024_linux.pdf
2023comp90024_linux.pdf2023comp90024_linux.pdf
2023comp90024_linux.pdf
 
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEAShell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEA
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 

More from Techvilla

Raspberry pi Part 26
Raspberry pi Part 26Raspberry pi Part 26
Raspberry pi Part 26
Techvilla
 
Raspberry pi Part 24
Raspberry pi Part 24Raspberry pi Part 24
Raspberry pi Part 24
Techvilla
 
Raspberry pi Part 23
Raspberry pi Part 23Raspberry pi Part 23
Raspberry pi Part 23
Techvilla
 
Raspberry pi Part 22
Raspberry pi Part 22Raspberry pi Part 22
Raspberry pi Part 22
Techvilla
 
Raspberry pi Part 21
Raspberry pi Part 21Raspberry pi Part 21
Raspberry pi Part 21
Techvilla
 
Raspberry pi Part 20
Raspberry pi Part 20Raspberry pi Part 20
Raspberry pi Part 20
Techvilla
 
Raspberry pi Part 19
Raspberry pi Part 19Raspberry pi Part 19
Raspberry pi Part 19
Techvilla
 
Raspberry pi Part 18
Raspberry pi Part 18Raspberry pi Part 18
Raspberry pi Part 18
Techvilla
 
Raspberry pi Part 17
Raspberry pi Part 17Raspberry pi Part 17
Raspberry pi Part 17
Techvilla
 
Raspberry pi Part 16
Raspberry pi Part 16Raspberry pi Part 16
Raspberry pi Part 16
Techvilla
 
Rasperry pi Part 15
Rasperry pi Part 15Rasperry pi Part 15
Rasperry pi Part 15
Techvilla
 
Rasperry pi Part 13
Rasperry pi Part 13Rasperry pi Part 13
Rasperry pi Part 13
Techvilla
 
Rasperry pi Part 12
Rasperry pi Part 12Rasperry pi Part 12
Rasperry pi Part 12
Techvilla
 
Rasperry pi Part 10
Rasperry pi Part 10Rasperry pi Part 10
Rasperry pi Part 10
Techvilla
 
Rasperry pi Part 9
Rasperry pi Part 9Rasperry pi Part 9
Rasperry pi Part 9
Techvilla
 
Rasperry pi Part 8
Rasperry pi Part 8Rasperry pi Part 8
Rasperry pi Part 8
Techvilla
 
Rasperry pi Part 7
Rasperry pi Part 7Rasperry pi Part 7
Rasperry pi Part 7
Techvilla
 
Raspberry pi Part 6
Raspberry pi Part 6Raspberry pi Part 6
Raspberry pi Part 6
Techvilla
 
Raspberry pi Part 5
Raspberry pi Part 5Raspberry pi Part 5
Raspberry pi Part 5
Techvilla
 
Raspberry pi Part 3
Raspberry pi Part 3Raspberry pi Part 3
Raspberry pi Part 3
Techvilla
 

More from Techvilla (20)

Raspberry pi Part 26
Raspberry pi Part 26Raspberry pi Part 26
Raspberry pi Part 26
 
Raspberry pi Part 24
Raspberry pi Part 24Raspberry pi Part 24
Raspberry pi Part 24
 
Raspberry pi Part 23
Raspberry pi Part 23Raspberry pi Part 23
Raspberry pi Part 23
 
Raspberry pi Part 22
Raspberry pi Part 22Raspberry pi Part 22
Raspberry pi Part 22
 
Raspberry pi Part 21
Raspberry pi Part 21Raspberry pi Part 21
Raspberry pi Part 21
 
Raspberry pi Part 20
Raspberry pi Part 20Raspberry pi Part 20
Raspberry pi Part 20
 
Raspberry pi Part 19
Raspberry pi Part 19Raspberry pi Part 19
Raspberry pi Part 19
 
Raspberry pi Part 18
Raspberry pi Part 18Raspberry pi Part 18
Raspberry pi Part 18
 
Raspberry pi Part 17
Raspberry pi Part 17Raspberry pi Part 17
Raspberry pi Part 17
 
Raspberry pi Part 16
Raspberry pi Part 16Raspberry pi Part 16
Raspberry pi Part 16
 
Rasperry pi Part 15
Rasperry pi Part 15Rasperry pi Part 15
Rasperry pi Part 15
 
Rasperry pi Part 13
Rasperry pi Part 13Rasperry pi Part 13
Rasperry pi Part 13
 
Rasperry pi Part 12
Rasperry pi Part 12Rasperry pi Part 12
Rasperry pi Part 12
 
Rasperry pi Part 10
Rasperry pi Part 10Rasperry pi Part 10
Rasperry pi Part 10
 
Rasperry pi Part 9
Rasperry pi Part 9Rasperry pi Part 9
Rasperry pi Part 9
 
Rasperry pi Part 8
Rasperry pi Part 8Rasperry pi Part 8
Rasperry pi Part 8
 
Rasperry pi Part 7
Rasperry pi Part 7Rasperry pi Part 7
Rasperry pi Part 7
 
Raspberry pi Part 6
Raspberry pi Part 6Raspberry pi Part 6
Raspberry pi Part 6
 
Raspberry pi Part 5
Raspberry pi Part 5Raspberry pi Part 5
Raspberry pi Part 5
 
Raspberry pi Part 3
Raspberry pi Part 3Raspberry pi Part 3
Raspberry pi Part 3
 

Recently uploaded

block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 

Recently uploaded (20)

block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 

Raspberry pi Part 4

  • 2. www.techvilla.org.in Working with the Shell  What is shell?  Different shells in linux.  Programming in shell.  Shell vs windows cmd
  • 3. www.techvilla.org.in What’s Shell?  It’s acts an interface between the user and OS (kernel).It’s known as “ command interpreter”.  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)
  • 4. www.techvilla.org.in Shell basics  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 Kernel Other programs X window bash csh
  • 5. www.techvilla.org.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 !)
  • 6. www.techvilla.org.in Shell as a Language  We can write a script containing many shell commands  Interactive Program:  grep files with POSIX string and print it % for file in * > do > if grep –l POSIX $file > then > more $file  fi  done Posix There is a file with POSIX in it  ‘*’ is wildcard % more `grep –l POSIX *` % more $(grep –l POSIX *) % more –l POSIX * | more
  • 7. www.techvilla.org.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)
  • 8. www.techvilla.org.in Syntax  Variables  Conditions  Control  Lists  Functions  Shell Commands  Result  Document
  • 9. www.techvilla.org.in Variables  Variables needed to be declared, note it is case-sensitive (e.g. foo, FOO, Foo)  Add ‘$’ for storing values % salutation=Hello % echo $salutation Hello % salutation=7+5 % echo $salutation 7+5 % salutation=“yes dear” % echo $salutation yes dear % read salutation Hola! % echo $salutation Hola!
  • 10. www.techvilla.org.in Quoting  Edit a “vartest.sh” file #!/bin/sh myvar=“Hi there” echo $myvar echo “$myvar” echo `$myvar` echo $myvar echo Enter some text read myvar echo ‘$myvar’ now equals $myvar exit 0 Output Hi there Hi there $myvar $myvar Enter some text Hello world $myvar now equals Hello world
  • 11. www.techvilla.org.in Environment Variables  $HOME home directory  $PATH path  $PS1 第一層提示符號 (normally %)  $PS2 第二層提示符號 (normally >)  $$ process id of the script  $# number of input parameters  $0 name of the script file  $IFS separation character (white space)  Use ‘env’ to check the value
  • 12. www.techvilla.org.in Shell vs windows cmd  The difference of Windows and Linux  Case sensitive in Linux  / in Linux  No relationship between executable file and extension  don't search current path  Security policy is more strict in Linux  link file VS shortcut