Your SlideShare is downloading. ×
bash
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

bash

2,090
views

Published on

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

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,090
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
44
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. bash g 11/2010 Akron Linux User Group
  • 2. macroprocessor program that expands text and symbols to create large expressions
  • 3. shell macroprocessor to execute commands
  • 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. 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. bash documentation man bash man builtins man rbash man bashbug
  • 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. 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. 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. 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. bash modes default (non POSIX) POSIX
  • 12. bash: POSIX mode set -o posix #now in POSIX mode
  • 13. bash: POSIX mode example of variance: set builtin does not show you func defs
  • 14. bash: POSIX mode subset of bash core no process substitution why use it?
  • 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. readline documentation man bash then type /READLINE <enter>
  • 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. bash tips Execute your script, after marking it executable chmod +x myscript.sh; ./myscript.sh
  • 19. bash tips Expansions! echo a{z,y,x}b
  • 20. bash tips Append echo "This is me" > saveforlater echo "This is also me" >> saveforlater
  • 21. bash tips Redirect output and error to different files . myprogram 1>myoutput 2>myerrors To the same file . myprogram >&alloutput . myprogram &>alloutput
  • 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. 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. 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. 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. 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. bash tips modern loops: for i in $(seq 1 10); do echo $i; done
  • 28. bash tips loops from the past: for i in {1..10}; do echo $i; done
  • 29. bash tips loops that are the most portable: for ((i=0; i<10; i++)); do echo $i; done
  • 30. bash tips portable stdout: printf "%s" "short string"
  • 31. bash tips what does the machine see: hexdump -C myfavoritebigfile
  • 32. YOUR bash tips
  • 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/