SlideShare a Scribd company logo
Shell Commands
and
Shell Scripts
Presented By:
Nazmul Hyder
ID- 011 131 085
Shell Command
Identity and Manual
Command Description
$uame Linux will tell you his name to you
$whoami If you want to know your name
$man uname For each command manual
Continue..
Editors
Command Description
$ kwrite File write
$gedit File Edit
$vi
Continue..
File Listing
Command Description
$ls -a Do not hide entries starting with.
$ls -h Print size in human readable format
$ls -l Use a long listing format
$ls -s Sort by file size
Continue..
Directory Operations
Command Description
$pwd If u want to see your current directory
$cd “directory name” To change the directory
$mkdir “directory name” Create a new directory
$rmdir “directory name” Remove an empty directory
$rmdir -r “directory name” Remove directory with file
Continue..
File Operations
Command Description
$cp “file” “copyfile.txt” Copy file
$rm “file.txt” To remove file
$mv “file.txt “ “directory name” Create a new directory
$file -i “file name” To know the file type
$file -v “file name” Print the version of the file
$cat “file1” “file2” To concat files and print on the
standard output
Continue..
File Viewing
Command Description
$echo “some text” You can a line of text in the shell
$more file.txt It uses for the Spacebar and the B key for
the forward and backward navigation
$less “file.txt” Less allows forward and backward
movement using arrow keys
$head filename To see the first 10 contents of the file
$tail filename To see the last 10 contents of the file
Continue..
File Viewing
Command Description
$filename -n To print the line number of the file
$sort file1 file2 To write the sorted concatenation of all
the file and standard output
$wc filename Print bytes,words,total lines
$wc -l or -w You can see specific
Continue..
Piping and Grep
Command Description
$head -10 a.txt | tail -5 To see 5-10 number lines of a file
$grep “a” file.txt Print lines which contains “a”
$grep -i For case insensitive search
$grep -c Count total matches
$grep -n Display the line number of matches
Continue..
Grep
Command Description
$grep -E [^F] filename Anything except capital F
$grep -E [$a] filename Anything that ends with a
$grep -E [a-zA-Z] filename Anything that contains small a to z and
capital A to Z
Shell Script
Advantage of shell script :
● It take input from user , file and output them on screen.
● Useful to create own commands.
● Save time.
Continue..
Write and Execute :
● We can use any editor to write the shell script.
● The extension is .sh
● Two thing you can need to do before execute file
○ Chmod +x script_name “set execute permission for your script”
○ ./script_name “execute script”
Continue..
Shell Script Examples
Arithmetic if-else Case
#!/bin/bash
expr 1 + 1
expr 1 ‐1
expr 1 * 1
expr 1 / 1
var=`expr 1 + 1`
x=1
x=`expr $x + 1`
#!/bin/bash
echo "Enter first number "
read num1
echo "Enter second number"
read num2
if [ $num1 ‐gt $num2 ] ; then
echo
"$num1 is greater than $num2"
elif [ $num1 ‐lt $num2 ] ; then
echo "$num1 is less than $num2"
else
echo "$num1 and $num2 are equal"
fi
#!/bin/sh
echo “Is it morning? Please answer
yes or no”
read timeofday
case “$timeofday” in
yes) echo “Good Morning”;;
no ) echo “Good Afternoon”;;
y ) echo “Good Morning”;;
n ) echo “Good Afternoon”;;
* ) echo “Sorry, answer not
recognized”;;
esac
Thank You

More Related Content

What's hot

Class & sub class
Class & sub classClass & sub class
Class & sub class
HSS-Software House
 
Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities
Ahmed El-Arabawy
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filters
bhatvijetha
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
iCreateWorld
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commands
Nomura Japanese Investment Bank
 
Unit 7 standard i o
Unit 7 standard i oUnit 7 standard i o
Unit 7 standard i o
root_fibo
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
Dr.Ravi
 
Namespace1
Namespace1Namespace1
Namespace1
zindadili
 
Basic basic solaris quick referent card
Basic basic solaris quick referent cardBasic basic solaris quick referent card
Basic basic solaris quick referent card
Bui Van Cuong
 
Bash4
Bash4Bash4
Bash4
apsegundo
 
Mkscript sh
Mkscript shMkscript sh
Mkscript sh
Ben Pope
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell Script
Dr.Ravi
 
Crystal Rocks
Crystal RocksCrystal Rocks
Crystal Rocks
Brian Cardiff
 
Using Unix
Using UnixUsing Unix
Using Unix
Dr.Ravi
 
Raspberry pi Part 4
Raspberry pi Part 4Raspberry pi Part 4
Raspberry pi Part 4
Techvilla
 
Airlover 20030324 1
Airlover 20030324 1Airlover 20030324 1
Airlover 20030324 1
Dr.Ravi
 
Logrotate sh
Logrotate shLogrotate sh
Logrotate sh
Ben Pope
 
Cscope and ctags
Cscope and ctagsCscope and ctags
Cscope and ctags
Saikat Megamind
 
Talk Unix Shell Script 1
Talk Unix Shell Script 1Talk Unix Shell Script 1
Talk Unix Shell Script 1
Dr.Ravi
 
Cli deep dive
Cli deep diveCli deep dive
Cli deep dive
Edward Capriolo
 

What's hot (20)

Class & sub class
Class & sub classClass & sub class
Class & sub class
 
Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filters
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commands
 
Unit 7 standard i o
Unit 7 standard i oUnit 7 standard i o
Unit 7 standard i o
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
 
Namespace1
Namespace1Namespace1
Namespace1
 
Basic basic solaris quick referent card
Basic basic solaris quick referent cardBasic basic solaris quick referent card
Basic basic solaris quick referent card
 
Bash4
Bash4Bash4
Bash4
 
Mkscript sh
Mkscript shMkscript sh
Mkscript sh
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell Script
 
Crystal Rocks
Crystal RocksCrystal Rocks
Crystal Rocks
 
Using Unix
Using UnixUsing Unix
Using Unix
 
Raspberry pi Part 4
Raspberry pi Part 4Raspberry pi Part 4
Raspberry pi Part 4
 
Airlover 20030324 1
Airlover 20030324 1Airlover 20030324 1
Airlover 20030324 1
 
Logrotate sh
Logrotate shLogrotate sh
Logrotate sh
 
Cscope and ctags
Cscope and ctagsCscope and ctags
Cscope and ctags
 
Talk Unix Shell Script 1
Talk Unix Shell Script 1Talk Unix Shell Script 1
Talk Unix Shell Script 1
 
Cli deep dive
Cli deep diveCli deep dive
Cli deep dive
 

Similar to Linux Shell Scripts and Shell Commands✌️

Examples -partII
Examples -partIIExamples -partII
Examples -partII
Kedar Bhandari
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
Shakeel Shafiq
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
hazhamina
 
Directories description
Directories descriptionDirectories description
Directories description
Dr.M.Karthika parthasarathy
 
Unix / Linux Command Reference
Unix / Linux Command ReferenceUnix / Linux Command Reference
Unix / Linux Command Reference
Sumankumar Panchal
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
jinal thakrar
 
Unix Trainning Doc.pptx
Unix Trainning Doc.pptxUnix Trainning Doc.pptx
Unix Trainning Doc.pptx
KalpeshRaut7
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 
Unix cmd
Unix cmdUnix cmd
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja
Ranjan Raja
 
Workshop on command line tools - day 1
Workshop on command line tools - day 1Workshop on command line tools - day 1
Workshop on command line tools - day 1
Leandro Lima
 
Building robust and friendly command line applications in go
Building robust and friendly command line applications in goBuilding robust and friendly command line applications in go
Building robust and friendly command line applications in go
Andrii Soldatenko
 
Introduction to the linux command line.pdf
Introduction to the linux command line.pdfIntroduction to the linux command line.pdf
Introduction to the linux command line.pdf
CesleySCruz
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
TECHWORLDwithphotoed
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
GowthamRaju15
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
Harikrishnan Ramakrishnan
 
Lnx
LnxLnx
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
Kuntal Bhowmick
 
Unix lab
Unix labUnix lab
part2.pdf
part2.pdfpart2.pdf

Similar to Linux Shell Scripts and Shell Commands✌️ (20)

Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
Directories description
Directories descriptionDirectories description
Directories description
 
Unix / Linux Command Reference
Unix / Linux Command ReferenceUnix / Linux Command Reference
Unix / Linux Command Reference
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
Unix Trainning Doc.pptx
Unix Trainning Doc.pptxUnix Trainning Doc.pptx
Unix Trainning Doc.pptx
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
Unix cmd
Unix cmdUnix cmd
Unix cmd
 
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja
 
Workshop on command line tools - day 1
Workshop on command line tools - day 1Workshop on command line tools - day 1
Workshop on command line tools - day 1
 
Building robust and friendly command line applications in go
Building robust and friendly command line applications in goBuilding robust and friendly command line applications in go
Building robust and friendly command line applications in go
 
Introduction to the linux command line.pdf
Introduction to the linux command line.pdfIntroduction to the linux command line.pdf
Introduction to the linux command line.pdf
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Lnx
LnxLnx
Lnx
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
 
Unix lab
Unix labUnix lab
Unix lab
 
part2.pdf
part2.pdfpart2.pdf
part2.pdf
 

More from Nazmul Hyder

Analysis of Tree in Computer Based Application
Analysis of Tree in Computer Based ApplicationAnalysis of Tree in Computer Based Application
Analysis of Tree in Computer Based Application
Nazmul Hyder
 
Classification by clustering
Classification by clustering Classification by clustering
Classification by clustering
Nazmul Hyder
 
Language Translator ( Compiler)
Language Translator ( Compiler)Language Translator ( Compiler)
Language Translator ( Compiler)
Nazmul Hyder
 
Huffman coding
Huffman coding Huffman coding
Huffman coding
Nazmul Hyder
 
Dataset Analysis using weka tools (pattern recognition)
Dataset Analysis using weka tools (pattern recognition)Dataset Analysis using weka tools (pattern recognition)
Dataset Analysis using weka tools (pattern recognition)
Nazmul Hyder
 
ODOO documentation(e-commerce +accounting+purchase+inventory+invoice+HR+ POS)
ODOO documentation(e-commerce +accounting+purchase+inventory+invoice+HR+ POS)ODOO documentation(e-commerce +accounting+purchase+inventory+invoice+HR+ POS)
ODOO documentation(e-commerce +accounting+purchase+inventory+invoice+HR+ POS)
Nazmul Hyder
 
E-commerce (System Analysis and Design)
E-commerce (System Analysis and Design)E-commerce (System Analysis and Design)
E-commerce (System Analysis and Design)
Nazmul Hyder
 
Benchmark analysis (Online Shopping System)
Benchmark analysis (Online Shopping System)Benchmark analysis (Online Shopping System)
Benchmark analysis (Online Shopping System)
Nazmul Hyder
 
Online medicine store (using ODOO)
Online medicine store (using ODOO)Online medicine store (using ODOO)
Online medicine store (using ODOO)
Nazmul Hyder
 
Data analysis in artificial intelligence
Data analysis in artificial intelligenceData analysis in artificial intelligence
Data analysis in artificial intelligence
Nazmul Hyder
 

More from Nazmul Hyder (10)

Analysis of Tree in Computer Based Application
Analysis of Tree in Computer Based ApplicationAnalysis of Tree in Computer Based Application
Analysis of Tree in Computer Based Application
 
Classification by clustering
Classification by clustering Classification by clustering
Classification by clustering
 
Language Translator ( Compiler)
Language Translator ( Compiler)Language Translator ( Compiler)
Language Translator ( Compiler)
 
Huffman coding
Huffman coding Huffman coding
Huffman coding
 
Dataset Analysis using weka tools (pattern recognition)
Dataset Analysis using weka tools (pattern recognition)Dataset Analysis using weka tools (pattern recognition)
Dataset Analysis using weka tools (pattern recognition)
 
ODOO documentation(e-commerce +accounting+purchase+inventory+invoice+HR+ POS)
ODOO documentation(e-commerce +accounting+purchase+inventory+invoice+HR+ POS)ODOO documentation(e-commerce +accounting+purchase+inventory+invoice+HR+ POS)
ODOO documentation(e-commerce +accounting+purchase+inventory+invoice+HR+ POS)
 
E-commerce (System Analysis and Design)
E-commerce (System Analysis and Design)E-commerce (System Analysis and Design)
E-commerce (System Analysis and Design)
 
Benchmark analysis (Online Shopping System)
Benchmark analysis (Online Shopping System)Benchmark analysis (Online Shopping System)
Benchmark analysis (Online Shopping System)
 
Online medicine store (using ODOO)
Online medicine store (using ODOO)Online medicine store (using ODOO)
Online medicine store (using ODOO)
 
Data analysis in artificial intelligence
Data analysis in artificial intelligenceData analysis in artificial intelligence
Data analysis in artificial intelligence
 

Recently uploaded

Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
shreyassri1208
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
heathfieldcps1
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
nitinpv4ai
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
Kalna College
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17
Celine George
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
Kalna College
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
Nguyen Thanh Tu Collection
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
RandolphRadicy
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
sonukumargpnirsadhan
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 

Recently uploaded (20)

Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 

Linux Shell Scripts and Shell Commands✌️

  • 1. Shell Commands and Shell Scripts Presented By: Nazmul Hyder ID- 011 131 085
  • 2. Shell Command Identity and Manual Command Description $uame Linux will tell you his name to you $whoami If you want to know your name $man uname For each command manual
  • 3. Continue.. Editors Command Description $ kwrite File write $gedit File Edit $vi
  • 4. Continue.. File Listing Command Description $ls -a Do not hide entries starting with. $ls -h Print size in human readable format $ls -l Use a long listing format $ls -s Sort by file size
  • 5. Continue.. Directory Operations Command Description $pwd If u want to see your current directory $cd “directory name” To change the directory $mkdir “directory name” Create a new directory $rmdir “directory name” Remove an empty directory $rmdir -r “directory name” Remove directory with file
  • 6. Continue.. File Operations Command Description $cp “file” “copyfile.txt” Copy file $rm “file.txt” To remove file $mv “file.txt “ “directory name” Create a new directory $file -i “file name” To know the file type $file -v “file name” Print the version of the file $cat “file1” “file2” To concat files and print on the standard output
  • 7. Continue.. File Viewing Command Description $echo “some text” You can a line of text in the shell $more file.txt It uses for the Spacebar and the B key for the forward and backward navigation $less “file.txt” Less allows forward and backward movement using arrow keys $head filename To see the first 10 contents of the file $tail filename To see the last 10 contents of the file
  • 8. Continue.. File Viewing Command Description $filename -n To print the line number of the file $sort file1 file2 To write the sorted concatenation of all the file and standard output $wc filename Print bytes,words,total lines $wc -l or -w You can see specific
  • 9. Continue.. Piping and Grep Command Description $head -10 a.txt | tail -5 To see 5-10 number lines of a file $grep “a” file.txt Print lines which contains “a” $grep -i For case insensitive search $grep -c Count total matches $grep -n Display the line number of matches
  • 10. Continue.. Grep Command Description $grep -E [^F] filename Anything except capital F $grep -E [$a] filename Anything that ends with a $grep -E [a-zA-Z] filename Anything that contains small a to z and capital A to Z
  • 11. Shell Script Advantage of shell script : ● It take input from user , file and output them on screen. ● Useful to create own commands. ● Save time.
  • 12. Continue.. Write and Execute : ● We can use any editor to write the shell script. ● The extension is .sh ● Two thing you can need to do before execute file ○ Chmod +x script_name “set execute permission for your script” ○ ./script_name “execute script”
  • 13. Continue.. Shell Script Examples Arithmetic if-else Case #!/bin/bash expr 1 + 1 expr 1 ‐1 expr 1 * 1 expr 1 / 1 var=`expr 1 + 1` x=1 x=`expr $x + 1` #!/bin/bash echo "Enter first number " read num1 echo "Enter second number" read num2 if [ $num1 ‐gt $num2 ] ; then echo "$num1 is greater than $num2" elif [ $num1 ‐lt $num2 ] ; then echo "$num1 is less than $num2" else echo "$num1 and $num2 are equal" fi #!/bin/sh echo “Is it morning? Please answer yes or no” read timeofday case “$timeofday” in yes) echo “Good Morning”;; no ) echo “Good Afternoon”;; y ) echo “Good Morning”;; n ) echo “Good Afternoon”;; * ) echo “Sorry, answer not recognized”;; esac