SlideShare ist ein Scribd-Unternehmen logo
1 von 86
Downloaden Sie, um offline zu lesen
Text shells
Matt Mokary
and important productivity tips
TERMINAL-ogy
● Terminal window terminal window
TERMINAL-ogy
● Terminal window
● Terminal emulator
terminal emulator
terminal window
TERMINAL-ogy
● Terminal window
● Terminal emulator
terminal emulator
terminal window
TERMINAL-ogy
● Terminal window
● Terminal emulator
● Shell
terminal emulator
shell
terminal window
Modern Shells
● C Shell (csh)
● Bourne Again Shell (bash)
● Korn Shell (ksh)
● Z Shell (zsh)
Modern Shells
● C Shell (csh)
● Bourne Again Shell (bash)
● Korn Shell (ksh)
● Z Shell (zsh)
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ ls
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ ls
Applications Documents Library
Desktop Downloads Music
$
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ ls -a
<program name> <program flags> [ arg1, arg2, … ]
$ ls -a
drwxr-xr-x 3 mattmokary staff 102 Feb 24 12:56 Applications
drwx------+ 5 mattmokary staff 170 Mar 20 17:06 Desktop
drwx------+ 11 mattmokary staff 374 Mar 20 12:03 Documents
drwx------+ 56 mattmokary staff 1904 Mar 20 14:54 Downloads
drwx------@ 49 mattmokary staff 1666 Feb 12 15:42 Library
drwx------+ 5 mattmokary staff 170 Feb 20 00:12 Music
$
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ grep -n TODO MyProject.java
Basic usage
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ grep -n TODO MyProject.java
23: // TODO is there an off-by-one error here?
131: // TODO document this function
340: // TODO make this more efficient
$
<program name> <program flags> [ arg1, arg2, … ]
$ gcc -o HelloWorld hello_world.c
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ gcc -o HelloWorld hello_world.c
$
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ gcc -o HelloWorld hello_world.c
$ ls
HelloWorld hello_world.c hello_world.o
$
Basic usage
Streams
Streams
● Standard Input (stdin)
Streams
● Standard Input (stdin)
● Standard Output (stdout)
Streams
● Standard Input (stdin)
● Standard Output (stdout)
● Standard Error (stderr)
Streams
$ cat test.txt
Streams
$ cat test.txt
This is a test file.
It has several lines,
none of which are very helpful.
This is the last line of the file.
$
Stream Redirection
● >
Stream Redirection
● > $ grep TODO MyProject.java
Stream Redirection
● > $ grep TODO MyProject.java
// TODO make this better
// TODO delete these
$
Stream Redirection
● > $ grep TODO MyProject.java > todo.txt
Stream Redirection
● > $ grep TODO MyProject.java > todo.txt
$
Stream Redirection
● > $ grep TODO MyProject.java > todo.txt
$ ls
MyProject.java todo.txt
$
Stream Redirection
● > $ grep TODO MyProject.java > todo.txt
$ ls
MyProject.java todo.txt
$ cat todo.txt
// TODO make this better
// TODO delete these
$
Stream Redirection
● >
>>
$ grep TODO MyProject.java > todo.txt
$ ls
MyProject.java todo.txt
$ cat todo.txt
// TODO make this better
// TODO delete these
$
Stream Redirection
● >
>>
● <
Stream Redirection
● >
>>
● <
$ grep TODO MyProject.java
// TODO make this better
// TODO delete these
$
Stream Redirection
● >
>>
● <
$ grep TODO < MyProject.java
// TODO make this better
// TODO delete these
$
Stream Redirection
● >
>>
● <
● |
Stream Redirection
● >
>>
● <
● |
$ grep TODO MyProject.java > todo.txt
$ wc -l todo.txt
2
$ rm todo.txt
Stream Redirection
● >
>>
● <
● |
$ grep TODO MyProject.java | wc -l
Stream Redirection
● >
>>
● <
● |
$ grep TODO MyProject.java | wc -l
2
Stream Redirection
● >
>>
● <
● |
$ grep TODO MyProject.java | wc -l
2
$ ruby get_hockey_tweets.rb 
| grep -in sedin | grep -i henrik 
| wc -l
173
$
Stream Redirection
● > redirect stdout to file stream
>> append stdout to file stream
● < redirect file stream to stdin
● | redirect stdout and stderr to stdin
Stream Redirection
● stdin (channel 0)
● stdout (channel 1)
● stderr (channel 2)
Stream Redirection
$ ./sqrt -1 2> errors.txt
No real solution.
$
Stream Redirection
$ ./sqrt -1 2> errors.txt
No real solution.
$ cat errors.txt
Argument is less than zero.
$
Stream Redirection
$ ./sqrt -1 2> errors.txt 1> /dev/null
$ cat errors.txt
Argument is less than zero.
$
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
$
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
$ ls
postfix-solver syntax-errors.txt
$
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
$ ls
postfix-solver syntax-errors.txt
$ cat syntax-errors.txt
$
Stream Redirection
● stdin 0
● stdout 1
● stderr 2
● 2> redirect stderr to file stream
● 2>&1 redirect stderr to current stdout
etc.
Every SE Ever:
Every SE Ever:
“I have no idea why this isn’t working.”
Every SE Ever:
“I have no idea why this isn’t working.”
“I have no idea why this is working.”
Every SE Ever:
“I have no idea why this isn’t working.”
“I have no idea why this is working.”
“How do I get out of vim?”
vim Modes
● Normal
vim Modes
● Normal
o insert a new line beneath the cursor, move to it,
and enter insert mode
$ move to the end of the line and remain in
normal mode
i enter insert mode at the cursor’s current
position
I move to the beginning of the line and enter
insert mode
dd cut the current line
vim Modes
● Normal
● Insert
vim Modes
● Normal
● Insert
● Command
vim Modes
● Normal
● Insert
● Command
:w write the buffer to the disk
:q quit vim; will stop you if the file has changed
since the last write
:q! quit vim and discard changes since last write
:wq write the buffer and quit vim
:x same as :wq
:<some number>
move the cursor to line <some number>
Typical vim Workflow
Typical vim Workflow
$ vim some-file.txt
Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
enter normal mode and write the file with “:w”
Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
enter normal mode and write the file with “:w”
enter normal mode
Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
enter normal mode and write the file with “:w”
enter normal mode
write the file and quit vim with “:wq” or “:x”
vim Visual Mode
vim Visual Mode
x cut the highlighted text and save it to vim’s
clipboard
y copy the highlighted text and save it to vim’s
clipboard
p (in normal mode)
paste the text in vim’s clipboard into the buffer
after the cursor
P (in normal mode)
paste the text in vim’s clipboard into the buffer
before the cursor
tmux
tmux
$ Shell
tmux
$ tmux new -s Crypto
$
Shell
tmux session
“Crypto”
tmux
$ tmux new -s Crypto
$ tmux ls
Crypto: 1 windows … (attached)
$
Shell
tmux session
“Crypto”
tmux
$ tmux new -s Crypto
$ tmux ls
Crypto: 1 windows … (attached)
$ tmux detach
$
Shell
tmux session
“Crypto”
tmux
$ tmux new -s Crypto
$ tmux ls
Crypto: 1 windows … (attached)
$ tmux detach
$ tmux new -s Grading
$
Shell
tmux session
“Crypto”
tmux session
“Grading”
tmux
$ tmux new -s Crypto
$ tmux ls
Crypto: 1 windows … (attached)
$ tmux detach
$ tmux new -s Grading
$ tmux kill-session -t Crypto
$
Shell
tmux session
“Grading”
tmux
$ tmux new -s Crypto
$ tmux ls
Crypto: 1 windows … (attached)
$ tmux detach
$ tmux new -s Grading
$ tmux kill-session -t Crypto
$ tmux detach
$
Shell
tmux session
“Grading”
tmux Session
tmux Session
CTRL+b % vertical split
tmux Session
CTRL+b % vertical split
CTRL+b “ horizontal
split
tmux Session
CTRL+b % vertical split
CTRL+b “ horizontal
split
CTRL+b x y kill pane
tmux Session
CTRL+b % vertical split
CTRL+b “ horizontal
split
CTRL+b x y kill pane
CTRL+b arrows
navigate panes
My Personal Setup
Thanks!

Weitere ähnliche Inhalte

Was ist angesagt?

Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSH
webelement
 

Was ist angesagt? (20)

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
 
Fast HTTP string processing algorithms
Fast HTTP string processing algorithmsFast HTTP string processing algorithms
Fast HTTP string processing algorithms
 
groovy & grails - lecture 4
groovy & grails - lecture 4groovy & grails - lecture 4
groovy & grails - lecture 4
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part A
 
Processes And Job Control
Processes And Job ControlProcesses And Job Control
Processes And Job Control
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationRedis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your application
 
Node.js streaming csv downloads proxy
Node.js streaming csv downloads proxyNode.js streaming csv downloads proxy
Node.js streaming csv downloads proxy
 
Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSH
 
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scripting
 
R snippet
R snippetR snippet
R snippet
 
Class
ClassClass
Class
 
Getting groovy (ODP)
Getting groovy (ODP)Getting groovy (ODP)
Getting groovy (ODP)
 
Redis as a message queue
Redis as a message queueRedis as a message queue
Redis as a message queue
 
Tech talk 01.06.2017
Tech talk 01.06.2017Tech talk 01.06.2017
Tech talk 01.06.2017
 
Simple tricks to speed you up on the command line
Simple tricks to speed you up on the command lineSimple tricks to speed you up on the command line
Simple tricks to speed you up on the command line
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
 
realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係
 

Ähnlich wie Unix shell talk - RIT SSE

Biicode OpenExpoDay
Biicode OpenExpoDayBiicode OpenExpoDay
Biicode OpenExpoDay
fcofdezc
 
101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects
Acácio Oliveira
 
II BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptxII BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptx
Savitha74
 
Tuffarsi in vim
Tuffarsi in vimTuffarsi in vim
Tuffarsi in vim
sambismo
 

Ähnlich wie Unix shell talk - RIT SSE (20)

Biicode OpenExpoDay
Biicode OpenExpoDayBiicode OpenExpoDay
Biicode OpenExpoDay
 
101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects
 
101 3.4 use streams, pipes and redirects v2
101 3.4 use streams, pipes and redirects v2101 3.4 use streams, pipes and redirects v2
101 3.4 use streams, pipes and redirects v2
 
3.4 use streams, pipes and redirects v2
3.4 use streams, pipes and redirects v23.4 use streams, pipes and redirects v2
3.4 use streams, pipes and redirects v2
 
Devel::hdb debugger talk
Devel::hdb debugger talkDevel::hdb debugger talk
Devel::hdb debugger talk
 
Gun make
Gun makeGun make
Gun make
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Love Your Command Line
Love Your Command LineLove Your Command Line
Love Your Command Line
 
II BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptxII BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptx
 
Tuffarsi in vim
Tuffarsi in vimTuffarsi in vim
Tuffarsi in vim
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
Vim Eye for the Rails Guy - Cheatsheet
Vim Eye for the Rails Guy - CheatsheetVim Eye for the Rails Guy - Cheatsheet
Vim Eye for the Rails Guy - Cheatsheet
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
shellScriptAlt.pptx
shellScriptAlt.pptxshellScriptAlt.pptx
shellScriptAlt.pptx
 
Understanding Autovacuum
Understanding AutovacuumUnderstanding Autovacuum
Understanding Autovacuum
 
Adrian Mouat - Docker Tips and Tricks
 Adrian Mouat - Docker Tips and Tricks Adrian Mouat - Docker Tips and Tricks
Adrian Mouat - Docker Tips and Tricks
 
One-Liners to Rule Them All
One-Liners to Rule Them AllOne-Liners to Rule Them All
One-Liners to Rule Them All
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Unix shell talk - RIT SSE