SlideShare uma empresa Scribd logo
1 de 55
Baixar para ler offline
Lesson 7
• Bash Keywords
• Command-Line Editing
• Variable Assignments and Displaying Messages
• Multiple Commands – printf
• Command History
• Directory Commands – pwd
• Specialized Navigation and History
• Colon Command
• Shell Aliases
• Bash Hash Table
• Job States
Bash Keywords
A keyword is a word or symbol that has a special meaning to a computer language.
The following symbols and words have special meanings to Bash when they are
unquoted and the first word of a command.
! esac select }
case fi then [[
do for until ]]
done function while
elif if time
else in {
Unlike most computer languages, Bash allows keywords to be used as variable
names even though this can make scripts difficult to read.
keep scripts understandable, keywords should not be used for variable names.
Use the shell with files and directories
Directory Operations
The pwd Command
The ls Command
Long List Option
Directory Structure Recursive List
The mkdir Command
The cd Command
The rmdir Command
Regular File Utilities
The more Command
Operations Common to Directories and Files
The cp Command
Simple File Copy
Copy File to A Directory From Home
Copy and Rename File
Recursive Copy
Recursive Copy with Subdirectories
Wildcard Copies
The mv Command
Move File
The ln Command
The rm Command
The find Command
Commands
Command-Line Editing
multiple commands
Command-Line Editing
There are special key combinations to edit what you type or to repeat commands.
Bash has two editing modes.
These modes emulate the keys used in two Linux text editors.
Vi mode mimics the vi and vim editors.
Emacs mode works like emacs, nano or pico.
The current editing mode can be checked with the shopt command.
shopt -o emacs in emacs mode.
shopt -o vi in vi mode.
Only one mode can be on at a time.
$ shopt -o emacs
emacs on
$ shopt -o vi
vi off
Command-Line Editing
Regardless of the mode, the arrow keys move the cursor and step through the
most recently executed command:
Left arrow—Moves back one character to the left. No characters are erased.
Right arrow—Moves forward one character to the right.
Up arrow—Moves to the previous command in the command history.
Down arrow—Moves to the next command in the command history (if any).
Emacs mode is the default mode on all the major Linux distributions.
The most common emacs keys are:
control-b—Moves back one character to the left. No characters are erased.
control-f—Moves forward one character to the right.
control-p—Moves to the previous command in the command history.
control-n—Moves to the next command in the command history (if any).
Tab key—Finds a matching filename and completes it if there is one exact match.
Command-Line Editing
complete list of key combinations (or bindings) listed in the Bash man page Readline section.
The default key combinations can be changed, listed, or reassigned using the bind command.
Other editing keys are controlled by the older Linux stty (set teletype) command.
Running stty shows common command keys and information about your session.
Use the -a (all) switch for all settings.
$ stty
speed 9600 baud; evenp hupcl
intr = ^C; erase = ^?; kill = ^X;
eol2 = ^@; swtch = ^@;
susp = ^Z; dsusp = ^Y;
werase = ^W; lnext = ^@;
-inpck -istrip icrnl -ixany ixoff onlcr
-iexten echo echoe echok
-echoctl -echoke
Many settings are used only when working with serial port devices and can be ignored.
The other settings are control key combinations marked with a caret (^) symbol.
Keys with ^@ (or ASCII 0) are not defined.
To change the suspend character to control-v, type
$ stty susp ‘^v’
Command-Line Editing
key combinations marked with a caret (^) symbol.
erase (usually ^?, which is the backspace key on IBM-style keyboards)
—Moves left and erases one character.
intr (usually ^C)
—Interrupts/stops the current program or cancels the current line.
kill (usually ^X)
—Erases the current line.
rprnt (usually ^R)
—Redraws the current line.
stop (usually ^S)
—Pauses the program so you can read the results on the screen.
start (usually ^Q)
—Resumes the program.
susp (usually ^Z)
—Suspends the current program.
werase (usually ^W)
—Erases the last word typed.
Variable Assignments and Displaying Messages
Variables can be created and assigned text using an equals sign.
Surround the text with double quotes.
$ FILENAME=”info.txt”
The value of variables can be printed using the printf command.
printf has two arguments: a formatting code, and the variable to display.
For simple variables, the formatting code is “%sn” and the variable name should appear in
double quotes with a dollar sign in front of the name:
$ printf “%sn” “$FILENAME”
info.txt
printf can also display simple messages.
Put the message in the place of the formatting code:
$ printf “Bash is a great shell.n”
Bash is a great shell.
Multiple Commands - printf
printf is very similar to the C standard I/O printf() function, but they are not identical.
In particular, single- and double-quoted strings are treated differently in shell scripts than in C programs.
first parameter is a format string describing how the items being printed will be represented.
For example, “%d” represents an integer number, and code “%f” represents a floating-point number.
$ printf “%dn” 5
5
$ printf “%fn” 5
5.000000
• Include a format code for each item you want to print.
• Each format code is replaced with the appropriate value when printed.
• Any characters in format string not part of formatting instruction are treated as printable
characters.
$ printf “There are %d customers with purchases over %d.n” 50 20000
There are 50 customers with purchases over 20000.
Multiple Commands - printf
The format codes include:
%a —Represent a floating-point number in hexadecimal format, using lowercase letters
%A —Represent a floating point number in hexadecimal format, using uppercase letters
%b —Expand backslash sequences
%c —Represent a single character
%d —Display a signed number
%e —Display a floating-point number, shown in exponential (also called “scientific”) notation
%f (or %F) —Display a floating-point number without exponential notation
%g —(General) Let Bash choose %e or %f, depending on the value
%i —Same as %d
%0 —Display an octal number
%q —Quote a string so it can be read properly by a shell script
%s —Display an unquoted string
%u —Display an unsigned number
%x —Display an unsigned hexadecimal number, using lowercase letters
%X —Display an unsigned hexadecimal number, using uppercase letters
%% —Display a percent sign
Multiple Commands - printf
formatting codes for the representation of unprintable characters.:
b —Backspace
f —Form feed (that is, eject a page on a printer)
n —Start a new line
r —Carriage return
t —Tab
v —Vertical tab
’ —Single quote character (for compatibility with C)
 —Backslash
0n —n is an octal number representing an 8-bit ASCII character
$ printf “Two separatenlinesn”
Two separate
Lines
Any 8-bit byte or ASCII character can be represented by 0 or  and its octal value.
$ printf “ASCII 65 (octal 101) is the character 0101n”
ASCII 65 (octal 101) is the character A
Variable Assignments and Displaying Messages - printf
printf and variables play an important role in shell scripting
The results of a command can be assigned to a variable using backquotes.
$ DATE=`date`
$ printf “%sn” “$DATE”
Wed Feb 13 15:36:41 EST 2012
The date shown is the date when the variable DATE is assigned its value.
The value of the variable remains the same until a new value is assigned.
$ printf “%sn” “$DATE”
Wed Feb 13 15:36:41 EST 2012
$ DATE=`date`
$ printf “%sn” “$DATE”
Wed Feb 13 15:36:48 EST 2012
Multiple Commands - printf
Multiple commands can be combined on a single line.
How they are executed depends on what symbols separate them.
If each command is separated by a semicolon (;)
the commands are executed consecutively, one after another.
$ printf “%sn” “This is executed” ; printf “%sn” “And so is this”
This is executed
And so is this
If each command is separated by a double ampersand (&&)
the commands are executed until one of them fails or until all the commands are executed.
$ date && printf “%sn” “The date command was successful”
Wed Aug 15 14:36:32 EDT 2012
The date command was successful
If each command is separated by a double vertical bar (||)
the commands are executed as long as each one fails until all the commands are executed.
$ date ‘duck!’ || printf “%sn” “The date command failed”
date: bad conversion
The date command failed
Multiple Commands - printf
Semicolons, double ampersands, and double vertical bars can be mixed in a single line.
$ date ‘format-this!’ || printf “%sn” “The date command failed” && 
printf “%sn” “But the printf didn’t!”
date: bad conversion
The date command failed
But the printf didn’t!
These are primarily intended as command-line shortcuts.
When mixed with redirection operators such as >, a long command chain is difficult to read
and should be avoided in scripts.
Command History
Bash keeps a list of the most recently typed commands. This list is the command history.
The easiest way to browse the command history is with the Up and Down arrow keys
The history can also be searched with an exclamation mark (!).
This denotes the start of a command name to be completed by Bash. Bash executes the most
recent command that matches. Example:
$ date
Wed Apr 4 11:55:58 EDT 2012
$ !d
Wed Apr 4 11:55:58 EDT 2012
If there is no matching command, Bash replies with an event not found error message.
$ !x
bash: !x: event not found
double ! repeats the last command.
$ date
Thu Jul 5 14:03:25 EDT 2012
$ !!
date
Thu Jul 5 14:03:28 EDT 2012
Command History
There are many variations of the ! command to provide shortcuts in specific situations.
A negative number indicates the relative line number.
That is, it indicates number of commands to move back in the history to find one to execute.
!! is the same as !-1.
$ date
Thu Jul 5 14:04:54 EDT 2012
$ printf “%sn” $PWD
/home/bartsimpson/
$ !-2
date
Thu Jul 5 14:05:15 EDT 2012
The !# repeats the content of the current command line.
(Don’t confuse this with #! in shell scripts.) Use this to run a set of commands twice.
$ date ; sleep 5 ; !#
date ; sleep 5 ; date ; sleep 5 ;
Fri Jan 18 15:26:54 EST 2012
Fri Jan 18 15:26:59 EST 2012
Directory Commands - pwd
built-in pwd (present working directory) returns the name of current directory.
$ pwd
/home/bartsimpson
built-in cd (change directory) command changes your current directory.
.. represents the parent directory, . represents the current directory.
$ pwd
/home/bartsimpson
$ cd .
$ pwd
/home/bartsimpson
$ cd ..
$ pwd
/home
$ cd bartsimpson
$ pwd
/home/bartsimpson
Directory Commands - pwd
Each time you change the directory, Bash updates the variable PWD containing the
path to your current working directory.
Bash also maintains a second variable called OLDPWD that contains the last directory
you were in.
Using minus sign (–) with cd, you can switch between the current directory and last directory.
This is a useful shortcut to work in two different directories.
$ pwd
/home/kburtch
$ cd ..
$ pwd
/home
$ cd -
$ pwd
/home/kburtch
$ cd -
$ pwd
/home
Directory Commands
The tilde (~) represents your current directory.
Use it to move to a directory relative to your home directory.
To move to a directory called mail in your home directory, type
$ cd ~/mail
Specialized Navigation and History
built-in dirs command shows the list of saved directories.
The current directory is always the first item in the list.
$ dirs
~
built-in pushd (push directory) command adds (or pushes) directories onto list and changes the
current directory to the new directory.
$ pushd /home/bartsimpon/invoices
~/invoices ~
$ pushd /home/bartsimpon/work
~/work ~/invoices ~
$ pwd
/home/bartsimpson/work
There are now three directories in the list.
dirs -l switch displays the directory names without any short forms.
-n (no change) switch will put a directory into the list without changing directories.
-N (rotate Nth) moves the nth directory from the left (or, with +N, from the right) to the top of the list.
$ dirs -l
/home/bartsimpson/work /home/bartsimpson/invoices /home/bartsimpson
Specialized Navigation and History
built-in popd (pop directory) command is the opposite of the pushd.
popd discards the first directory and moves to the next directory in the list.
$ popd
~/invoices ~
$ pwd
/home/bartsimpson/invoices
The switches for popd are similar to pushd:
-n to pop without moving,
-N to delete the Nth entry from the left (or, with +N, the right).
Colon Command
The simplest shell command is the colon (:).
This is the colon command (called “no-op” or “null command”) and does nothing.
There are some places in shell programs where a statement is required.
In those cases, you can use : to indicate nothing special should be done.
At the command prompt, : has no effect.
$ :
$
The colon command can have parameters and file redirections.
This can have strange effects, such as running the date command using backquotes, giving the
results to the null command that quietly discards them.
$ : `date`
$
This has the same effect as redirecting the output of date to the /dev/null file.
$ date > /dev/null
Shell Aliases
An alias is a short form of a command.
built-in alias command creates simple abbreviations for current Bash session.
To create an alias, use the alias command to assign a command and its switches a name.
$ alias lf=’ls -qFl’
$ lf
-rw-r----- 1 bartsimpson devgroup 10809 Apr 6 11:00 assets.txt
-rw-r----- 1 bartsimposn devgroup 4713 Mar 9 2012 mailing_list.txt
Typing the alias command by itself, or with -p switch, lists the current aliases.
$ alias
alias lf=’ls -qFl’
Bash interprets an alias only once, allowing the aliasing of a command with its own name.
$ alias ls=’ls -qF’ # Bash isn’t confused
There is no method for giving arguments to an alias. If arguments are needed, define a more powerful shell function instead.
built-in unalias command removes an alias. Use the -a switch to remove them all.
Bash Hash Table
built-in hash command maintains the hash table.
Without any switches, hash lists the memorized commands, where they are, and the number of
times the command has been executed during this session.
$ hash
hits command
1 /bin/ls
1 /bin/uname
1 /usr/bin/tput
1 /bin/stty
1 /usr/bin/uptime
1 /usr/bin/man
When a command is specified, Bash searches for the new location of the command. For example, if you create
your own ls command in your current directory, and the PATH variable gives precedence to files in your current
directory, the hash ls command finds your ls command first, replacing /bin/ls with ./ls.
Job States
Job Control
Job control - Ability to selectively suspend execution of processes and continue their execution later.
A job is a process or a pipeline of processes that were started by the shell.
job which receives keyboard input is called the foreground job.
• When a foreground process is running, it receives keyboard input and signals.
• Processes started are run in foreground by default and continue until they exit.
To run a process in background – input command followed by special character &
• Processes running in the background may still send output to the terminal.
• They do not receive keyboard input unless they are brought to the foreground.
When bash starts a background job, it prints a line with:
- job number and - process ID of last process in pipeline
Job Control
command jobs displays current list of jobs either running or stopped.
foo:~ $ dd if=/dev/zero of=/dev/null bs=1 &
[1] 1181
foo:~ $ cat /dev/urandom | grep hello &
[2] 1183
foo:~ $ jobs
[1]- Running dd if=/dev/zero of=/dev/null bs=1 &
[2]+ Running cat /dev/urandom | grep hello &
Job Control
key sequences entered to foreground processes:
Key Signal Meaning Usage
Ctrl+C SIGINT Interrupt Interrupt the program running in the foreground
Ctrl+Z SIGSTOP Suspend Suspend the program running in the foreground
cmds entered to control background processes.
Command Meaning Usage
fg foreground Run the background job in the foreground. If it has suspended, restart it.
bg background Restart a suspended job.
fg makes most recently executed job a foreground job.
You can specify a specific job number. (Ex. fg 2 will make job 2 run in the foreground)
bg makes most recently executed job continue to run in background.
You can make a specific job run in the background by specifying a job number (Ex. bg 2)
Job Control
kill command
kill job based on job number (instead of PID) using percentage sign to specify the job number
foo:~ $ jobs
[1]- Running dd if=/dev/zero of=/dev/null bs=1 &
[2]+ Running cat /dev/urandom | grep hello &
foo:~ $ kill %1
foo:~ $
[1]- Terminated dd if=/dev/zero of=/dev/null bs=1
foo:~ $ jobs
[2]+ Running cat /dev/urandom | grep hello &
foo:~ $ kill %2
foo:~ $
[2]+ Terminated cat /dev/urandom | grep hello
Job Control
ps – process status
options supported by ps are somewhat complex.
GNU version supports: Unix98 options (letters); BSD options (dash); GNU options (two dashes).
To ... Unix98 BSD
- Show all processes ps -ax ps -A ps -e
- Show full info ps -u (user format) ps -f (full listing)
- Show full info for all processes ps -aux ps -ef ps -Af
foo:~ $ ps -f
UID PID PPID C STIME TTY TIME CMD
georgem 987 612 0 20:32 pts/2 00:00:00 /bin/bash
georgem 3398 987 0 21:11 pts/2 00:00:00 ps -f
foo:~ $ ps u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
georgem 987 0.0 1.7 4676 2040 pts/2 S 20:32 0:00 /bin/bash
georgem 3399 0.0 0.5 2524 696 pts/2 R 21:11 0:00 ps u
ps -w – display in wide format
ps -f – display in forest of processes, similar to output of pstree - hierarchical view
Job Control
top – displays processes that use up the most CPU or memory.

Mais conteúdo relacionado

Mais procurados (12)

Programming in perl style
Programming in perl styleProgramming in perl style
Programming in perl style
 
Bash
BashBash
Bash
 
Intro to Perl and Bioperl
Intro to Perl and BioperlIntro to Perl and Bioperl
Intro to Perl and Bioperl
 
Php
PhpPhp
Php
 
SAS Proc SQL
SAS Proc SQLSAS Proc SQL
SAS Proc SQL
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning Perl
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
Scalar expressions and control structures in perl
Scalar expressions and control structures in perlScalar expressions and control structures in perl
Scalar expressions and control structures in perl
 
Perl names values and variables
Perl names values and variablesPerl names values and variables
Perl names values and variables
 
Php Basic
Php BasicPhp Basic
Php Basic
 
Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern Perl
 
00 ruby tutorial
00 ruby tutorial00 ruby tutorial
00 ruby tutorial
 

Destaque

Tuning for Oracle RAC Wait Events
Tuning for Oracle RAC Wait EventsTuning for Oracle RAC Wait Events
Tuning for Oracle RAC Wait EventsConfio Software
 
Oracle 11g R2 RAC setup on rhel 5.0
Oracle 11g R2 RAC setup on rhel 5.0Oracle 11g R2 RAC setup on rhel 5.0
Oracle 11g R2 RAC setup on rhel 5.0Santosh Kangane
 
Oracle dba-concise-handbook
Oracle dba-concise-handbookOracle dba-concise-handbook
Oracle dba-concise-handbooksasi777
 
Oracle SQL Tuning for Day-to-Day Data Warehouse Support
Oracle SQL Tuning for Day-to-Day Data Warehouse SupportOracle SQL Tuning for Day-to-Day Data Warehouse Support
Oracle SQL Tuning for Day-to-Day Data Warehouse Supportnkarag
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuningSimon Huang
 
Oracle dba-daily-operations
Oracle dba-daily-operationsOracle dba-daily-operations
Oracle dba-daily-operationsraima sen
 
Top 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tipsTop 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tipsNirav Shah
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsEnkitec
 
Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning Kernel Training
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scriptingvceder
 
SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners an...
SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners an...SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners an...
SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners an...SaltStack
 
10 Problems with your RMAN backup script
10 Problems with your RMAN backup script10 Problems with your RMAN backup script
10 Problems with your RMAN backup scriptYury Velikanov
 
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web ScaleSaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web ScaleSaltStack
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Guy Harrison
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in LinuxAnu Chaudhry
 
Tutorial on automatic summarization
Tutorial on automatic summarizationTutorial on automatic summarization
Tutorial on automatic summarizationConstantin Orasan
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql TuningChris Adkin
 

Destaque (19)

3 summary
3 summary3 summary
3 summary
 
Tuning for Oracle RAC Wait Events
Tuning for Oracle RAC Wait EventsTuning for Oracle RAC Wait Events
Tuning for Oracle RAC Wait Events
 
Linux shell scripting
Linux shell scriptingLinux shell scripting
Linux shell scripting
 
Oracle 11g R2 RAC setup on rhel 5.0
Oracle 11g R2 RAC setup on rhel 5.0Oracle 11g R2 RAC setup on rhel 5.0
Oracle 11g R2 RAC setup on rhel 5.0
 
Oracle dba-concise-handbook
Oracle dba-concise-handbookOracle dba-concise-handbook
Oracle dba-concise-handbook
 
Oracle SQL Tuning for Day-to-Day Data Warehouse Support
Oracle SQL Tuning for Day-to-Day Data Warehouse SupportOracle SQL Tuning for Day-to-Day Data Warehouse Support
Oracle SQL Tuning for Day-to-Day Data Warehouse Support
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuning
 
Oracle dba-daily-operations
Oracle dba-daily-operationsOracle dba-daily-operations
Oracle dba-daily-operations
 
Top 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tipsTop 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tips
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 
Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
 
SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners an...
SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners an...SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners an...
SaltConf14 - Matthew Williams, Flowroute - Salt Virt for Linux contatiners an...
 
10 Problems with your RMAN backup script
10 Problems with your RMAN backup script10 Problems with your RMAN backup script
10 Problems with your RMAN backup script
 
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web ScaleSaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
SaltConf14 - Craig Sebenik, LinkedIn - SaltStack at Web Scale
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in Linux
 
Tutorial on automatic summarization
Tutorial on automatic summarizationTutorial on automatic summarization
Tutorial on automatic summarization
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql Tuning
 

Semelhante a Licão 07 operating the shell

Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing toolsroot_fibo
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on LinuxTushar B Kute
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell ScriptDr.Ravi
 
3 character strings and formatted input output
3  character strings and formatted input output3  character strings and formatted input output
3 character strings and formatted input outputMomenMostafa
 
scanf function in c, variations in conversion specifier
scanf function in c, variations in conversion specifierscanf function in c, variations in conversion specifier
scanf function in c, variations in conversion specifierherosaikiran
 
Talk Unix Shell Script 1
Talk Unix Shell Script 1Talk Unix Shell Script 1
Talk Unix Shell Script 1Dr.Ravi
 
Learning sed and awk
Learning sed and awkLearning sed and awk
Learning sed and awkYogesh Sawant
 
Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)Roy Zimmer
 
Hex file and regex cheat sheet
Hex file and regex cheat sheetHex file and regex cheat sheet
Hex file and regex cheat sheetMartin Cabrera
 
Cheatsheet: Hex file headers and regex
Cheatsheet: Hex file headers and regexCheatsheet: Hex file headers and regex
Cheatsheet: Hex file headers and regexKasper de Waard
 
Perl.predefined.variables
Perl.predefined.variablesPerl.predefined.variables
Perl.predefined.variablesKing Hom
 
You Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager NeedsYou Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager NeedsRoy Zimmer
 

Semelhante a Licão 07 operating the shell (20)

Shell scripting
Shell scriptingShell scripting
Shell scripting
 
First steps in C-Shell
First steps in C-ShellFirst steps in C-Shell
First steps in C-Shell
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing tools
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on Linux
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell Script
 
3 character strings and formatted input output
3  character strings and formatted input output3  character strings and formatted input output
3 character strings and formatted input output
 
scanf function in c, variations in conversion specifier
scanf function in c, variations in conversion specifierscanf function in c, variations in conversion specifier
scanf function in c, variations in conversion specifier
 
Unix
UnixUnix
Unix
 
Talk Unix Shell Script 1
Talk Unix Shell Script 1Talk Unix Shell Script 1
Talk Unix Shell Script 1
 
Emacs Cheatsheet
Emacs CheatsheetEmacs Cheatsheet
Emacs Cheatsheet
 
Learning sed and awk
Learning sed and awkLearning sed and awk
Learning sed and awk
 
Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)Plunging Into Perl While Avoiding the Deep End (mostly)
Plunging Into Perl While Avoiding the Deep End (mostly)
 
Hex file and regex cheat sheet
Hex file and regex cheat sheetHex file and regex cheat sheet
Hex file and regex cheat sheet
 
Cheatsheet: Hex file headers and regex
Cheatsheet: Hex file headers and regexCheatsheet: Hex file headers and regex
Cheatsheet: Hex file headers and regex
 
Perl.predefined.variables
Perl.predefined.variablesPerl.predefined.variables
Perl.predefined.variables
 
You Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager NeedsYou Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager Needs
 
Scripting and the shell in LINUX
Scripting and the shell in LINUXScripting and the shell in LINUX
Scripting and the shell in LINUX
 
Matlab commands
Matlab commandsMatlab commands
Matlab commands
 
Matlab commands
Matlab commandsMatlab commands
Matlab commands
 
Bash production guide
Bash production guideBash production guide
Bash production guide
 

Mais de Acácio Oliveira

Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptxSecurity+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptxSecurity+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptxSecurity+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptxSecurity+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptxSecurity+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptxSecurity+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptxSecurity+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptxSecurity+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptxSecurity+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptxSecurity+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptxSecurity+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....Acácio Oliveira
 
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptxSecurity+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptxSecurity+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...Acácio Oliveira
 
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptxSecurity+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptxSecurity+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptxSecurity+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptxSecurity+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptxSecurity+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptxAcácio Oliveira
 

Mais de Acácio Oliveira (20)

Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptxSecurity+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
 
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptxSecurity+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
 
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptxSecurity+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
 
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptxSecurity+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
 
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptxSecurity+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
 
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptxSecurity+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
 
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptxSecurity+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
 
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptxSecurity+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
 
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptxSecurity+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
 
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptxSecurity+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
 
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptxSecurity+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
 
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
 
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptxSecurity+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
 
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptxSecurity+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
 
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
 
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptxSecurity+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
 
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptxSecurity+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptx
 
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptxSecurity+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
 
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptxSecurity+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
 
Security+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptxSecurity+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptx
 

Último

UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 

Último (20)

UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 

Licão 07 operating the shell

  • 1. Lesson 7 • Bash Keywords • Command-Line Editing • Variable Assignments and Displaying Messages • Multiple Commands – printf • Command History • Directory Commands – pwd • Specialized Navigation and History • Colon Command • Shell Aliases • Bash Hash Table • Job States
  • 2. Bash Keywords A keyword is a word or symbol that has a special meaning to a computer language. The following symbols and words have special meanings to Bash when they are unquoted and the first word of a command. ! esac select } case fi then [[ do for until ]] done function while elif if time else in { Unlike most computer languages, Bash allows keywords to be used as variable names even though this can make scripts difficult to read. keep scripts understandable, keywords should not be used for variable names.
  • 3. Use the shell with files and directories
  • 14. Operations Common to Directories and Files
  • 17. Copy File to A Directory From Home
  • 20. Recursive Copy with Subdirectories
  • 28. Command-Line Editing There are special key combinations to edit what you type or to repeat commands. Bash has two editing modes. These modes emulate the keys used in two Linux text editors. Vi mode mimics the vi and vim editors. Emacs mode works like emacs, nano or pico. The current editing mode can be checked with the shopt command. shopt -o emacs in emacs mode. shopt -o vi in vi mode. Only one mode can be on at a time. $ shopt -o emacs emacs on $ shopt -o vi vi off
  • 29. Command-Line Editing Regardless of the mode, the arrow keys move the cursor and step through the most recently executed command: Left arrow—Moves back one character to the left. No characters are erased. Right arrow—Moves forward one character to the right. Up arrow—Moves to the previous command in the command history. Down arrow—Moves to the next command in the command history (if any). Emacs mode is the default mode on all the major Linux distributions. The most common emacs keys are: control-b—Moves back one character to the left. No characters are erased. control-f—Moves forward one character to the right. control-p—Moves to the previous command in the command history. control-n—Moves to the next command in the command history (if any). Tab key—Finds a matching filename and completes it if there is one exact match.
  • 30. Command-Line Editing complete list of key combinations (or bindings) listed in the Bash man page Readline section. The default key combinations can be changed, listed, or reassigned using the bind command. Other editing keys are controlled by the older Linux stty (set teletype) command. Running stty shows common command keys and information about your session. Use the -a (all) switch for all settings. $ stty speed 9600 baud; evenp hupcl intr = ^C; erase = ^?; kill = ^X; eol2 = ^@; swtch = ^@; susp = ^Z; dsusp = ^Y; werase = ^W; lnext = ^@; -inpck -istrip icrnl -ixany ixoff onlcr -iexten echo echoe echok -echoctl -echoke Many settings are used only when working with serial port devices and can be ignored. The other settings are control key combinations marked with a caret (^) symbol. Keys with ^@ (or ASCII 0) are not defined. To change the suspend character to control-v, type $ stty susp ‘^v’
  • 31. Command-Line Editing key combinations marked with a caret (^) symbol. erase (usually ^?, which is the backspace key on IBM-style keyboards) —Moves left and erases one character. intr (usually ^C) —Interrupts/stops the current program or cancels the current line. kill (usually ^X) —Erases the current line. rprnt (usually ^R) —Redraws the current line. stop (usually ^S) —Pauses the program so you can read the results on the screen. start (usually ^Q) —Resumes the program. susp (usually ^Z) —Suspends the current program. werase (usually ^W) —Erases the last word typed.
  • 32. Variable Assignments and Displaying Messages Variables can be created and assigned text using an equals sign. Surround the text with double quotes. $ FILENAME=”info.txt” The value of variables can be printed using the printf command. printf has two arguments: a formatting code, and the variable to display. For simple variables, the formatting code is “%sn” and the variable name should appear in double quotes with a dollar sign in front of the name: $ printf “%sn” “$FILENAME” info.txt printf can also display simple messages. Put the message in the place of the formatting code: $ printf “Bash is a great shell.n” Bash is a great shell.
  • 33. Multiple Commands - printf printf is very similar to the C standard I/O printf() function, but they are not identical. In particular, single- and double-quoted strings are treated differently in shell scripts than in C programs. first parameter is a format string describing how the items being printed will be represented. For example, “%d” represents an integer number, and code “%f” represents a floating-point number. $ printf “%dn” 5 5 $ printf “%fn” 5 5.000000 • Include a format code for each item you want to print. • Each format code is replaced with the appropriate value when printed. • Any characters in format string not part of formatting instruction are treated as printable characters. $ printf “There are %d customers with purchases over %d.n” 50 20000 There are 50 customers with purchases over 20000.
  • 34. Multiple Commands - printf The format codes include: %a —Represent a floating-point number in hexadecimal format, using lowercase letters %A —Represent a floating point number in hexadecimal format, using uppercase letters %b —Expand backslash sequences %c —Represent a single character %d —Display a signed number %e —Display a floating-point number, shown in exponential (also called “scientific”) notation %f (or %F) —Display a floating-point number without exponential notation %g —(General) Let Bash choose %e or %f, depending on the value %i —Same as %d %0 —Display an octal number %q —Quote a string so it can be read properly by a shell script %s —Display an unquoted string %u —Display an unsigned number %x —Display an unsigned hexadecimal number, using lowercase letters %X —Display an unsigned hexadecimal number, using uppercase letters %% —Display a percent sign
  • 35. Multiple Commands - printf formatting codes for the representation of unprintable characters.: b —Backspace f —Form feed (that is, eject a page on a printer) n —Start a new line r —Carriage return t —Tab v —Vertical tab ’ —Single quote character (for compatibility with C) —Backslash 0n —n is an octal number representing an 8-bit ASCII character $ printf “Two separatenlinesn” Two separate Lines Any 8-bit byte or ASCII character can be represented by 0 or and its octal value. $ printf “ASCII 65 (octal 101) is the character 0101n” ASCII 65 (octal 101) is the character A
  • 36. Variable Assignments and Displaying Messages - printf printf and variables play an important role in shell scripting The results of a command can be assigned to a variable using backquotes. $ DATE=`date` $ printf “%sn” “$DATE” Wed Feb 13 15:36:41 EST 2012 The date shown is the date when the variable DATE is assigned its value. The value of the variable remains the same until a new value is assigned. $ printf “%sn” “$DATE” Wed Feb 13 15:36:41 EST 2012 $ DATE=`date` $ printf “%sn” “$DATE” Wed Feb 13 15:36:48 EST 2012
  • 37. Multiple Commands - printf Multiple commands can be combined on a single line. How they are executed depends on what symbols separate them. If each command is separated by a semicolon (;) the commands are executed consecutively, one after another. $ printf “%sn” “This is executed” ; printf “%sn” “And so is this” This is executed And so is this If each command is separated by a double ampersand (&&) the commands are executed until one of them fails or until all the commands are executed. $ date && printf “%sn” “The date command was successful” Wed Aug 15 14:36:32 EDT 2012 The date command was successful If each command is separated by a double vertical bar (||) the commands are executed as long as each one fails until all the commands are executed. $ date ‘duck!’ || printf “%sn” “The date command failed” date: bad conversion The date command failed
  • 38. Multiple Commands - printf Semicolons, double ampersands, and double vertical bars can be mixed in a single line. $ date ‘format-this!’ || printf “%sn” “The date command failed” && printf “%sn” “But the printf didn’t!” date: bad conversion The date command failed But the printf didn’t! These are primarily intended as command-line shortcuts. When mixed with redirection operators such as >, a long command chain is difficult to read and should be avoided in scripts.
  • 39. Command History Bash keeps a list of the most recently typed commands. This list is the command history. The easiest way to browse the command history is with the Up and Down arrow keys The history can also be searched with an exclamation mark (!). This denotes the start of a command name to be completed by Bash. Bash executes the most recent command that matches. Example: $ date Wed Apr 4 11:55:58 EDT 2012 $ !d Wed Apr 4 11:55:58 EDT 2012 If there is no matching command, Bash replies with an event not found error message. $ !x bash: !x: event not found double ! repeats the last command. $ date Thu Jul 5 14:03:25 EDT 2012 $ !! date Thu Jul 5 14:03:28 EDT 2012
  • 40. Command History There are many variations of the ! command to provide shortcuts in specific situations. A negative number indicates the relative line number. That is, it indicates number of commands to move back in the history to find one to execute. !! is the same as !-1. $ date Thu Jul 5 14:04:54 EDT 2012 $ printf “%sn” $PWD /home/bartsimpson/ $ !-2 date Thu Jul 5 14:05:15 EDT 2012 The !# repeats the content of the current command line. (Don’t confuse this with #! in shell scripts.) Use this to run a set of commands twice. $ date ; sleep 5 ; !# date ; sleep 5 ; date ; sleep 5 ; Fri Jan 18 15:26:54 EST 2012 Fri Jan 18 15:26:59 EST 2012
  • 41. Directory Commands - pwd built-in pwd (present working directory) returns the name of current directory. $ pwd /home/bartsimpson built-in cd (change directory) command changes your current directory. .. represents the parent directory, . represents the current directory. $ pwd /home/bartsimpson $ cd . $ pwd /home/bartsimpson $ cd .. $ pwd /home $ cd bartsimpson $ pwd /home/bartsimpson
  • 42. Directory Commands - pwd Each time you change the directory, Bash updates the variable PWD containing the path to your current working directory. Bash also maintains a second variable called OLDPWD that contains the last directory you were in. Using minus sign (–) with cd, you can switch between the current directory and last directory. This is a useful shortcut to work in two different directories. $ pwd /home/kburtch $ cd .. $ pwd /home $ cd - $ pwd /home/kburtch $ cd - $ pwd /home
  • 43. Directory Commands The tilde (~) represents your current directory. Use it to move to a directory relative to your home directory. To move to a directory called mail in your home directory, type $ cd ~/mail
  • 44. Specialized Navigation and History built-in dirs command shows the list of saved directories. The current directory is always the first item in the list. $ dirs ~ built-in pushd (push directory) command adds (or pushes) directories onto list and changes the current directory to the new directory. $ pushd /home/bartsimpon/invoices ~/invoices ~ $ pushd /home/bartsimpon/work ~/work ~/invoices ~ $ pwd /home/bartsimpson/work There are now three directories in the list. dirs -l switch displays the directory names without any short forms. -n (no change) switch will put a directory into the list without changing directories. -N (rotate Nth) moves the nth directory from the left (or, with +N, from the right) to the top of the list. $ dirs -l /home/bartsimpson/work /home/bartsimpson/invoices /home/bartsimpson
  • 45. Specialized Navigation and History built-in popd (pop directory) command is the opposite of the pushd. popd discards the first directory and moves to the next directory in the list. $ popd ~/invoices ~ $ pwd /home/bartsimpson/invoices The switches for popd are similar to pushd: -n to pop without moving, -N to delete the Nth entry from the left (or, with +N, the right).
  • 46. Colon Command The simplest shell command is the colon (:). This is the colon command (called “no-op” or “null command”) and does nothing. There are some places in shell programs where a statement is required. In those cases, you can use : to indicate nothing special should be done. At the command prompt, : has no effect. $ : $ The colon command can have parameters and file redirections. This can have strange effects, such as running the date command using backquotes, giving the results to the null command that quietly discards them. $ : `date` $ This has the same effect as redirecting the output of date to the /dev/null file. $ date > /dev/null
  • 47. Shell Aliases An alias is a short form of a command. built-in alias command creates simple abbreviations for current Bash session. To create an alias, use the alias command to assign a command and its switches a name. $ alias lf=’ls -qFl’ $ lf -rw-r----- 1 bartsimpson devgroup 10809 Apr 6 11:00 assets.txt -rw-r----- 1 bartsimposn devgroup 4713 Mar 9 2012 mailing_list.txt Typing the alias command by itself, or with -p switch, lists the current aliases. $ alias alias lf=’ls -qFl’ Bash interprets an alias only once, allowing the aliasing of a command with its own name. $ alias ls=’ls -qF’ # Bash isn’t confused There is no method for giving arguments to an alias. If arguments are needed, define a more powerful shell function instead. built-in unalias command removes an alias. Use the -a switch to remove them all.
  • 48. Bash Hash Table built-in hash command maintains the hash table. Without any switches, hash lists the memorized commands, where they are, and the number of times the command has been executed during this session. $ hash hits command 1 /bin/ls 1 /bin/uname 1 /usr/bin/tput 1 /bin/stty 1 /usr/bin/uptime 1 /usr/bin/man When a command is specified, Bash searches for the new location of the command. For example, if you create your own ls command in your current directory, and the PATH variable gives precedence to files in your current directory, the hash ls command finds your ls command first, replacing /bin/ls with ./ls.
  • 50. Job Control Job control - Ability to selectively suspend execution of processes and continue their execution later. A job is a process or a pipeline of processes that were started by the shell. job which receives keyboard input is called the foreground job. • When a foreground process is running, it receives keyboard input and signals. • Processes started are run in foreground by default and continue until they exit. To run a process in background – input command followed by special character & • Processes running in the background may still send output to the terminal. • They do not receive keyboard input unless they are brought to the foreground. When bash starts a background job, it prints a line with: - job number and - process ID of last process in pipeline
  • 51. Job Control command jobs displays current list of jobs either running or stopped. foo:~ $ dd if=/dev/zero of=/dev/null bs=1 & [1] 1181 foo:~ $ cat /dev/urandom | grep hello & [2] 1183 foo:~ $ jobs [1]- Running dd if=/dev/zero of=/dev/null bs=1 & [2]+ Running cat /dev/urandom | grep hello &
  • 52. Job Control key sequences entered to foreground processes: Key Signal Meaning Usage Ctrl+C SIGINT Interrupt Interrupt the program running in the foreground Ctrl+Z SIGSTOP Suspend Suspend the program running in the foreground cmds entered to control background processes. Command Meaning Usage fg foreground Run the background job in the foreground. If it has suspended, restart it. bg background Restart a suspended job. fg makes most recently executed job a foreground job. You can specify a specific job number. (Ex. fg 2 will make job 2 run in the foreground) bg makes most recently executed job continue to run in background. You can make a specific job run in the background by specifying a job number (Ex. bg 2)
  • 53. Job Control kill command kill job based on job number (instead of PID) using percentage sign to specify the job number foo:~ $ jobs [1]- Running dd if=/dev/zero of=/dev/null bs=1 & [2]+ Running cat /dev/urandom | grep hello & foo:~ $ kill %1 foo:~ $ [1]- Terminated dd if=/dev/zero of=/dev/null bs=1 foo:~ $ jobs [2]+ Running cat /dev/urandom | grep hello & foo:~ $ kill %2 foo:~ $ [2]+ Terminated cat /dev/urandom | grep hello
  • 54. Job Control ps – process status options supported by ps are somewhat complex. GNU version supports: Unix98 options (letters); BSD options (dash); GNU options (two dashes). To ... Unix98 BSD - Show all processes ps -ax ps -A ps -e - Show full info ps -u (user format) ps -f (full listing) - Show full info for all processes ps -aux ps -ef ps -Af foo:~ $ ps -f UID PID PPID C STIME TTY TIME CMD georgem 987 612 0 20:32 pts/2 00:00:00 /bin/bash georgem 3398 987 0 21:11 pts/2 00:00:00 ps -f foo:~ $ ps u USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND georgem 987 0.0 1.7 4676 2040 pts/2 S 20:32 0:00 /bin/bash georgem 3399 0.0 0.5 2524 696 pts/2 R 21:11 0:00 ps u ps -w – display in wide format ps -f – display in forest of processes, similar to output of pstree - hierarchical view
  • 55. Job Control top – displays processes that use up the most CPU or memory.