0
bash
g
11/2010
Akron Linux User Group
macroprocessor
program that expands text and symbols to create large
expressions
shell
macroprocessor to execute commands
shell standard
IEEE POSIX and Open Group shell specification
http://www.opengroup.org/onlinepubs/9699919799/nframe.html
Al...
bash
shell that interprets certain default commands and that provides
programmatic tools to write custom commands that don...
bash documentation
man bash
man builtins
man rbash
man bashbug
bash feature summary 1/2
source:http://tiswww.case.edu/php/chet/bash/bash-intro.html
editing and completion
history and co...
bash feature summary 2/2
source:http://tiswww.case.edu/php/chet/bash/bash-intro.html
indirect variable expansion
i/o capab...
bash breakdown of tasks
read text (terminal, file, string)
find words and operators
parse tokens into commands
expand cert...
bash: types of expansions
tilde
~
variable
str=abcdefgh; echo ${str:-3:2}
command
echo `date`
process
cmp < (echo "my life...
bash modes
default (non POSIX)
POSIX
bash: POSIX mode
set -o posix #now in POSIX mode
bash: POSIX mode
example of variance:
set builtin does not show you func defs
bash: POSIX mode
subset of bash core
no process substitution
why use it?
readline
bash + readline = productivity
readline allows you to make edits to commands
maintained by Chet as well
typically...
readline documentation
man bash
then type /READLINE <enter>
readline: take home
C-b move back one
C-f move forward one
C-d delete character I'm on
C-u undo last keystroke (infinitely...
bash tips
Execute your script, after marking it executable
chmod +x myscript.sh; ./myscript.sh
bash tips
Expansions!
echo a{z,y,x}b
bash tips
Append
echo "This is me" > saveforlater
echo "This is also me" >> saveforlater
bash tips
Redirect output and error to different files
. myprogram 1>myoutput 2>myerrors
To the same file
. myprogram >&al...
bash tips
First or last few lines
head novel_that_i_started_but_didnt_finish
tail novel_that_i_started_but_didnt_finish
ta...
bash tips
First or last few lines
head novel_that_i_started_but_didnt_finish
tail novel_that_i_started_but_didnt_finish
ta...
bash tips
accidental overwrites
echo "Test String" > 1.file
echo "Test String2" > 1.file
set -o noclobber
echo "Test Strin...
bash tips
accidental overwrites
echo "Test String" > 1.file
echo "Test String2" > 1.file
set -o noclobber
echo "Test Strin...
bash tips
incidental (conscious) overwrites
echo "Test String" > 1.file
echo "Test String2" > 1.file
set -o noclobber
echo...
bash tips
modern loops:
for i in $(seq 1 10); do echo $i; done
bash tips
loops from the past:
for i in {1..10}; do echo $i; done
bash tips
loops that are the most portable:
for ((i=0; i<10; i++)); do echo $i; done
bash tips
portable stdout:
printf "%s" "short string"
bash tips
what does the machine see:
hexdump -C myfavoritebigfile
YOUR bash tips
bash online
wiki:
http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29
stallman:
http://www.gnu.org/software/bash/
chet:
htt...
Upcoming SlideShare
Loading in...5
×

bash

2,134

Published on

Presentation I delivered that covered bash shell at Akron Linux User Group on 11/04/2010

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,134
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
45
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "bash"

  1. 1. bash g 11/2010 Akron Linux User Group
  2. 2. macroprocessor program that expands text and symbols to create large expressions
  3. 3. shell macroprocessor to execute commands
  4. 4. shell standard IEEE POSIX and Open Group shell specification http://www.opengroup.org/onlinepubs/9699919799/nframe.html All of these mean the same thing: POSIX.1-2008 IEEE Std 1003.1-2008 Open Group Technical Standard Base Specifications Issue 7"
  5. 5. bash shell that interprets certain default commands and that provides programmatic tools to write custom commands that don't exist can be used interactively (user types commands) or non- interactively (commands saved in a file) respects POSIX.1-2008 standard maintained by Chet Ramey at the moment
  6. 6. bash documentation man bash man builtins man rbash man bashbug
  7. 7. bash feature summary 1/2 source:http://tiswww.case.edu/php/chet/bash/bash-intro.html editing and completion history and command re-entry job control functions and aliases arrays arithmetic ansi c quote expansion tilde expansion brace expansion substring capabilities
  8. 8. bash feature summary 2/2 source:http://tiswww.case.edu/php/chet/bash/bash-intro.html indirect variable expansion i/o capability control of built-in commands shell optional behavior prompt customization security directory stack posix mode internationalization command timing
  9. 9. bash breakdown of tasks read text (terminal, file, string) find words and operators parse tokens into commands expand certain tokens into lists filenames commands arguments handle redirections execute commands wait for completion, or not
  10. 10. bash: types of expansions tilde ~ variable str=abcdefgh; echo ${str:-3:2} command echo `date` process cmp < (echo "my life") <(echo "your life") arithmetic str=abcdefgh; echo ${str:((-3)):2} brace echo sp{el,il,al}l
  11. 11. bash modes default (non POSIX) POSIX
  12. 12. bash: POSIX mode set -o posix #now in POSIX mode
  13. 13. bash: POSIX mode example of variance: set builtin does not show you func defs
  14. 14. bash: POSIX mode subset of bash core no process substitution why use it?
  15. 15. readline bash + readline = productivity readline allows you to make edits to commands maintained by Chet as well typically gets updated along with bash
  16. 16. readline documentation man bash then type /READLINE <enter>
  17. 17. readline: take home C-b move back one C-f move forward one C-d delete character I'm on C-u undo last keystroke (infinitely) C-a go to begin of line C-e go to end of line M-f jump forward (word) M-b jump backward (word) C-l clear screen, but keep my line plenty more..
  18. 18. bash tips Execute your script, after marking it executable chmod +x myscript.sh; ./myscript.sh
  19. 19. bash tips Expansions! echo a{z,y,x}b
  20. 20. bash tips Append echo "This is me" > saveforlater echo "This is also me" >> saveforlater
  21. 21. bash tips Redirect output and error to different files . myprogram 1>myoutput 2>myerrors To the same file . myprogram >&alloutput . myprogram &>alloutput
  22. 22. bash tips First or last few lines head novel_that_i_started_but_didnt_finish tail novel_that_i_started_but_didnt_finish tail +1000 novel_that_i_started_but_didnt_finish tail +1000 --lines=2000 novel_that_i_started_but_didnt_finish
  23. 23. bash tips First or last few lines head novel_that_i_started_but_didnt_finish tail novel_that_i_started_but_didnt_finish tail +1000 novel_that_i_started_but_didnt_finish tail +1000 --lines=2000 novel_that_i_started_but_didnt_finish
  24. 24. bash tips accidental overwrites echo "Test String" > 1.file echo "Test String2" > 1.file set -o noclobber echo "Test String3" > 1.file echo "Test String3" >> 1.file cat 1.file
  25. 25. bash tips accidental overwrites echo "Test String" > 1.file echo "Test String2" > 1.file set -o noclobber echo "Test String3" > 1.file #no go echo "Test String3" >> 1.file #still works cat 1.file
  26. 26. bash tips incidental (conscious) overwrites echo "Test String" > 1.file echo "Test String2" > 1.file set -o noclobber echo "Test String3" >| 1.file #goes echo "Test String3" >> 1.file #still works cat 1.file
  27. 27. bash tips modern loops: for i in $(seq 1 10); do echo $i; done
  28. 28. bash tips loops from the past: for i in {1..10}; do echo $i; done
  29. 29. bash tips loops that are the most portable: for ((i=0; i<10; i++)); do echo $i; done
  30. 30. bash tips portable stdout: printf "%s" "short string"
  31. 31. bash tips what does the machine see: hexdump -C myfavoritebigfile
  32. 32. YOUR bash tips
  33. 33. bash online wiki: http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29 stallman: http://www.gnu.org/software/bash/ chet: http://tiswww.case.edu/php/chet/bash/bashtop.html austin: http://www.unix.org/single_unix_specification_v3/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×