SlideShare a Scribd company logo
1 of 31
Download to read offline
Tarcisio Coutinho
16 Nov 2012
Dev-day
Linux - 101
Timeline
● 1965 :: MULTICS :: MTI, Bell Labs (AT&T) e General
Eletric
● 1969 :: Ken Thompson :: Unics (Assembly)
● 1971 :: Ken Thompson :: Rewrites the system on B
language (to solve portability problems)
● 1973 :: Thompson and Denis Richie :: C programming
language
● 1974 :: UNIX o/
● 1983 :: AT&T closes the UNIX's source code
● 1983 :: Andrew Tanenbaum :: MINIX
● 1984 :: Richard Stallman :: GNU (GCC, Emacs)
● 1991 :: Linux Torvalds :: GNU/Linux
GNU/Linux Distribution Timeline
http://futurist.se/gldt/
GNU/Linux
GNU/Linux Structure
Shell
What is Shell?
● Provides the command prompt and to interpret
commands
● Provides user interface for the OS and Kernel
Shell implementations
● bash (bourne again shell :: GNU implementation)
● ash (Almquist Shell :: BSD)
● csh (C shell :: BSD)
● tcsh (tee-shell)
● sh (Stephen Bourne)
● ksh (Korn shell)
Shell Variable Basics
● bash maintains a set of shell variables
○ PS1 :: Prompt String 1 :: Default interaction
○ PS2 :: Prompt String 1 :: Continuation interactive
prompt
○ PATH :: contains a list of all the directories that
hold commands or other programs you are likely to
execute
● bash variables are untyped
Export Variables
● When a variable is exported to the environment, it is
passed into the environment of all child processes
● let's go to the terminal
○ REDU="Redu Tech"
■ conventionally uppercase
○ echo $REDU or echo ${REDU}
■ $ prefix to interpret a shell var
○ echo "echo $REDU" | bash
Fun with PS1 :: Information
● u - Username
● h - Hostname
● w - Full path of the current woking directory
export PS1="u@h w"
export PS1="u@redu: w "
Fun with PS1 :: Colors
● e[ :: indicates the beginning of color
● x;ym :: indicates color code
● e[m :: indicates end of color prompt
White 1;37
Green 1;32
Cyan 1;36
Yellow 1;33
PS1="e[01;32mue[m@redu: w "
PS1="e[01;32mue[me[1;37m@e
[mredu: w "
PS1="e[01;32mue[me[1;37m@e
[me[1;36mredu:e[m w "
PS1="e[01;32mue[me[1;37m@e
[me[1;36mredu:e[me[1;33mwe
[m "
Streams, Pipes
and Redirects
Streams
● Everything is a file.
○ a program reading from the terminal’s device file
will receive characters typed at the keyboard
● When a program is launched, it is automatically
provided with three file descriptors
○ Standard input (abbreviated stdin) :: 0
○ Standard output (abbreviated stdout) :: 1
○ Standard error (abbreviated stderr) :: 2
● The standard input is different than parameters
Pipes and Redirects
● Pipes |
○ provides communication inter-process
■ tie the output of one program to the input of
another
■ e.g. echo "echo 'Hello Redu'" | bash
● Redirection
○ allows you to manage the origin of input streams
and the destination of output streams
■ > :: Redirection operator
■ >> :: Append operator
■ < :: Receive stdin from file
GNU and Unix
Commands
Tricks
● cd - :: go to the recent directory
○ Works with git branches
■ git checkout -
● !! :: call most recent command
○ bang-bang
● $( ) :: Command substitution or sub-shell
○ cd $(pwd)/..
GNU and Unix
sed & awk
Sed
● Stream based processing text editor
echo "sed tutorial. sed is a powerful text editor" |
sed 's/sed/awk/'
echo "sed tutorial. sed is a powerful text editor" |
sed 's/sed/awk/g'
echo "sed tutorial. sed is a powerful text editor" |
sed 's/sed/awk/2g'
Sed
echo "line without numbers nline with numbers: 1 2 3 " |
sed -r 's/[0-9]+/X/g'
echo "line without numbers nline with numbers: 1 2 3 " |
sed -rn 's/[0-9]+/X/g'
echo "line without numbers nline with numbers: 1 2 3 " |
sed -rn 's/[0-9]+/X/gp'
Sed
● Delete lines
○ sed '1,2-3 d' [FILE]
○ sed '/[pattern]/d [FILE]
○ sed -i '1 d' [FILE]
● Add lines
○ sed '/[pattern]/ i [text]' [FILE]
○ sed '/[pattern]/ a [text]' [FILE]
○ sed "1s/^/[text]" [FILE]
Awk
● AWK
○ processing text programming language
■ column based
awk -F [pattern] '{ [CMD] }'
$n -> variable from split by pattern match
ls -l | awk -F ' ' '{print $0}'
Quests
Fun with Seds
● Parse rails logs
○ Request count development.log
○ Top 10 most slow compound log job
grep awk head wc
uniq sort tail sed 'N;'
sed cut nl expand
tr
Dev-day
Linux - 101

More Related Content

What's hot

bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018AlastairRobertson9
 
Code Smart - Makefile (special release)
Code Smart - Makefile (special release)Code Smart - Makefile (special release)
Code Smart - Makefile (special release)Yu-Chuan Pi
 
IPython from 30,000 feet
IPython from 30,000 feetIPython from 30,000 feet
IPython from 30,000 feettakluyver
 
ncurses in your hobostove
ncurses in your hobostovencurses in your hobostove
ncurses in your hobostoveSmartLogic
 
Cryptography : From Demaratus to RSA
Cryptography : From Demaratus to RSACryptography : From Demaratus to RSA
Cryptography : From Demaratus to RSAbenlamm
 
Trip itparsing
Trip itparsingTrip itparsing
Trip itparsingCapIpad
 
関西Vim勉強会#5 vimrcの書き方
関西Vim勉強会#5 vimrcの書き方関西Vim勉強会#5 vimrcの書き方
関西Vim勉強会#5 vimrcの書き方tsukkee _
 
Graphics 32 bit
Graphics 32 bitGraphics 32 bit
Graphics 32 bitAsjad Ali
 
Doubly linklist
Doubly linklistDoubly linklist
Doubly linklistilsamaryum
 

What's hot (19)

Ssh
SshSsh
Ssh
 
bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018
 
Code Smart - Makefile (special release)
Code Smart - Makefile (special release)Code Smart - Makefile (special release)
Code Smart - Makefile (special release)
 
FSE 2008
FSE 2008FSE 2008
FSE 2008
 
IPython from 30,000 feet
IPython from 30,000 feetIPython from 30,000 feet
IPython from 30,000 feet
 
ncurses in your hobostove
ncurses in your hobostovencurses in your hobostove
ncurses in your hobostove
 
Unix command quickref
Unix command quickrefUnix command quickref
Unix command quickref
 
Cryptography : From Demaratus to RSA
Cryptography : From Demaratus to RSACryptography : From Demaratus to RSA
Cryptography : From Demaratus to RSA
 
Trip itparsing
Trip itparsingTrip itparsing
Trip itparsing
 
MFC Menu
MFC MenuMFC Menu
MFC Menu
 
Jose dossantos.doc
Jose dossantos.docJose dossantos.doc
Jose dossantos.doc
 
関西Vim勉強会#5 vimrcの書き方
関西Vim勉強会#5 vimrcの書き方関西Vim勉強会#5 vimrcの書き方
関西Vim勉強会#5 vimrcの書き方
 
Class & sub class
Class & sub classClass & sub class
Class & sub class
 
Graphics 32 bit
Graphics 32 bitGraphics 32 bit
Graphics 32 bit
 
Doubly linklist
Doubly linklistDoubly linklist
Doubly linklist
 
Code
CodeCode
Code
 
Script
ScriptScript
Script
 
Golang勉強会
Golang勉強会Golang勉強会
Golang勉強会
 
Linux for Beginners
Linux for  BeginnersLinux for  Beginners
Linux for Beginners
 

Similar to Dev day linux redu

Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Isham Rashik
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboyKenneth Geisshirt
 
Tips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyTips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyOlivier Bourgeois
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersKirk Kimmel
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboyKenneth Geisshirt
 
Terminals and Shells
Terminals and ShellsTerminals and Shells
Terminals and ShellsHoffman Lab
 
Linux tech talk
Linux tech talkLinux tech talk
Linux tech talkPrince Raj
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands101 3.1 gnu and unix commands
101 3.1 gnu and unix commandsAcácio Oliveira
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shellroot_fibo
 
Getting started with the Terminal
Getting started with the TerminalGetting started with the Terminal
Getting started with the TerminalWade Armstrong
 
01_linux_basics.ppt
01_linux_basics.ppt01_linux_basics.ppt
01_linux_basics.pptMahmood Adel
 
Tomáš Čorej: Configuration management & CFEngine3
Tomáš Čorej: Configuration management & CFEngine3Tomáš Čorej: Configuration management & CFEngine3
Tomáš Čorej: Configuration management & CFEngine3Jano Suchal
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linuxkishore1986
 
Unix fundamentals and_shell scripting
Unix fundamentals and_shell scriptingUnix fundamentals and_shell scripting
Unix fundamentals and_shell scriptingGanesh Bhosale
 

Similar to Dev day linux redu (20)

Unix Ramblings
Unix RamblingsUnix Ramblings
Unix Ramblings
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Tips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyTips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development Efficiency
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one liners
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
lect01.ppt
lect01.pptlect01.ppt
lect01.ppt
 
Terminals and Shells
Terminals and ShellsTerminals and Shells
Terminals and Shells
 
Linux tech talk
Linux tech talkLinux tech talk
Linux tech talk
 
Mac OSX Terminal 101
Mac OSX Terminal 101Mac OSX Terminal 101
Mac OSX Terminal 101
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands101 3.1 gnu and unix commands
101 3.1 gnu and unix commands
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shell
 
Getting started with the Terminal
Getting started with the TerminalGetting started with the Terminal
Getting started with the Terminal
 
01 linux basics
01 linux basics01 linux basics
01 linux basics
 
10.8.2018
10.8.201810.8.2018
10.8.2018
 
01_linux_basics.ppt
01_linux_basics.ppt01_linux_basics.ppt
01_linux_basics.ppt
 
Tomáš Čorej: Configuration management & CFEngine3
Tomáš Čorej: Configuration management & CFEngine3Tomáš Čorej: Configuration management & CFEngine3
Tomáš Čorej: Configuration management & CFEngine3
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linux
 
Linuxcommands 091018105536-phpapp01
Linuxcommands 091018105536-phpapp01Linuxcommands 091018105536-phpapp01
Linuxcommands 091018105536-phpapp01
 
Unix fundamentals and_shell scripting
Unix fundamentals and_shell scriptingUnix fundamentals and_shell scripting
Unix fundamentals and_shell scripting
 

Recently uploaded

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Recently uploaded (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Dev day linux redu

  • 1. Tarcisio Coutinho 16 Nov 2012 Dev-day Linux - 101
  • 2. Timeline ● 1965 :: MULTICS :: MTI, Bell Labs (AT&T) e General Eletric ● 1969 :: Ken Thompson :: Unics (Assembly) ● 1971 :: Ken Thompson :: Rewrites the system on B language (to solve portability problems) ● 1973 :: Thompson and Denis Richie :: C programming language ● 1974 :: UNIX o/ ● 1983 :: AT&T closes the UNIX's source code ● 1983 :: Andrew Tanenbaum :: MINIX ● 1984 :: Richard Stallman :: GNU (GCC, Emacs) ● 1991 :: Linux Torvalds :: GNU/Linux
  • 7. What is Shell? ● Provides the command prompt and to interpret commands ● Provides user interface for the OS and Kernel
  • 8. Shell implementations ● bash (bourne again shell :: GNU implementation) ● ash (Almquist Shell :: BSD) ● csh (C shell :: BSD) ● tcsh (tee-shell) ● sh (Stephen Bourne) ● ksh (Korn shell)
  • 9. Shell Variable Basics ● bash maintains a set of shell variables ○ PS1 :: Prompt String 1 :: Default interaction ○ PS2 :: Prompt String 1 :: Continuation interactive prompt ○ PATH :: contains a list of all the directories that hold commands or other programs you are likely to execute ● bash variables are untyped
  • 10. Export Variables ● When a variable is exported to the environment, it is passed into the environment of all child processes ● let's go to the terminal ○ REDU="Redu Tech" ■ conventionally uppercase ○ echo $REDU or echo ${REDU} ■ $ prefix to interpret a shell var ○ echo "echo $REDU" | bash
  • 11. Fun with PS1 :: Information ● u - Username ● h - Hostname ● w - Full path of the current woking directory
  • 14. Fun with PS1 :: Colors ● e[ :: indicates the beginning of color ● x;ym :: indicates color code ● e[m :: indicates end of color prompt White 1;37 Green 1;32 Cyan 1;36 Yellow 1;33
  • 20. Streams ● Everything is a file. ○ a program reading from the terminal’s device file will receive characters typed at the keyboard ● When a program is launched, it is automatically provided with three file descriptors ○ Standard input (abbreviated stdin) :: 0 ○ Standard output (abbreviated stdout) :: 1 ○ Standard error (abbreviated stderr) :: 2 ● The standard input is different than parameters
  • 21. Pipes and Redirects ● Pipes | ○ provides communication inter-process ■ tie the output of one program to the input of another ■ e.g. echo "echo 'Hello Redu'" | bash ● Redirection ○ allows you to manage the origin of input streams and the destination of output streams ■ > :: Redirection operator ■ >> :: Append operator ■ < :: Receive stdin from file
  • 23. Tricks ● cd - :: go to the recent directory ○ Works with git branches ■ git checkout - ● !! :: call most recent command ○ bang-bang ● $( ) :: Command substitution or sub-shell ○ cd $(pwd)/..
  • 25. Sed ● Stream based processing text editor echo "sed tutorial. sed is a powerful text editor" | sed 's/sed/awk/' echo "sed tutorial. sed is a powerful text editor" | sed 's/sed/awk/g' echo "sed tutorial. sed is a powerful text editor" | sed 's/sed/awk/2g'
  • 26. Sed echo "line without numbers nline with numbers: 1 2 3 " | sed -r 's/[0-9]+/X/g' echo "line without numbers nline with numbers: 1 2 3 " | sed -rn 's/[0-9]+/X/g' echo "line without numbers nline with numbers: 1 2 3 " | sed -rn 's/[0-9]+/X/gp'
  • 27. Sed ● Delete lines ○ sed '1,2-3 d' [FILE] ○ sed '/[pattern]/d [FILE] ○ sed -i '1 d' [FILE] ● Add lines ○ sed '/[pattern]/ i [text]' [FILE] ○ sed '/[pattern]/ a [text]' [FILE] ○ sed "1s/^/[text]" [FILE]
  • 28. Awk ● AWK ○ processing text programming language ■ column based awk -F [pattern] '{ [CMD] }' $n -> variable from split by pattern match ls -l | awk -F ' ' '{print $0}'
  • 30. Fun with Seds ● Parse rails logs ○ Request count development.log ○ Top 10 most slow compound log job grep awk head wc uniq sort tail sed 'N;' sed cut nl expand tr