Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shell Commands Using BASH Copyright © 2017 Curt Hill.

Similar presentations


Presentation on theme: "Shell Commands Using BASH Copyright © 2017 Curt Hill."— Presentation transcript:

1 Shell Commands Using BASH Copyright © 2017 Curt Hill

2 Introduction The standard UNIX 7 shell (sh) was written by Stephen Bourne Bourne Again SHell is the GNU rewrite of the original sh Written by Brian Fox Meant to be compatible with the sh Also influenced by the Korn shell and the C shell This presentation looks at some of these features Copyright © 2017 Curt Hill

3 Before This We have looked at several standard commands
File manipulation and the like Now we look at several other features Redirection Brace expansion Process management Copyright © 2017 Curt Hill

4 Redirection > < 2> &> | Redirect standard output
Redirect standard input 2> Redirect standard error &> Both out and err to same file | Pipe standard output to standard input of the next program Copyright © 2017 Curt Hill

5 Brace Expansion Items in braces are expanded into separate pieces
Thus a{p,g,l}e will become ape age ale This may be used for files or parameters Copyright © 2017 Curt Hill

6 More You may also use two dot ellipsis to show ranges
{a..d} produces a b c d A triple is like a for loop with start..end..incr { } produces { } also produces Only the last one needs to be a digit {a..i..2} produces a c e g i Copyright © 2017 Curt Hill

7 Examples ls –l *.{c,h,cpp,cxx} ls file{1..4}.txt
This will show most C/C++ sources ls file{1..4}.txt This will show only the series file1.txt, file2.txt, file3.txt and file4.txt Copyright © 2017 Curt Hill

8 Process Management Normally, we execute commands successfully
This is done by separating commands by a semicolon This can also be done by putting on separate lines You may also get the programs to run simultaneously by separating with an ampersand X & Y Copyright © 2017 Curt Hill

9 Process IDs When the ampersand is used we force a new process
This is shown with a Process ID (PID) and this is usually shown in brackets The kill command will stop a process by giving the Process ID Copyright © 2017 Curt Hill

10 Startup Scripts Bash may execute scripts by default
When it starts at login it attempts to execute /etc/profile Next it tries to execute .bash_profile, .bash_login and .profile from the current login directory The first one it finds it executes It attempts to execute .bash_logout when it exits Copyright © 2017 Curt Hill

11 Finally All of these features are characteristic of Bash in interactive mode Next we need to consider scripting Copyright © 2017 Curt Hill


Download ppt "Shell Commands Using BASH Copyright © 2017 Curt Hill."

Similar presentations


Ads by Google