Your SlideShare is downloading. ×
Bash 4
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 4

1,823
views

Published on

My presentation on Bash on loadays

My presentation on Bash on loadays

Published in: Business

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,823
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
49
Comments
0
Likes
0
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 4 Linux Open Administration Days Pieter Colpaert_
  • 2. #Understanding Bash >A little history >Reinventing UNIX #Speaking Bash #Bash 4 #_
  • 3. Understanding Bash_
  • 4. A little history (1970)
  • 5. And some UNIX today (2010) CC BY-SA – Larry Miller
  • 6. But also #Routers #Mainframes #Servers #Smartphones #PDA's #Toasters #..._
  • 7. Let's reinvent UNIX /rules/1# Writing software is one thing. Making it communicate is another_
  • 8. Let's reinvent UNIX #Communication >Systemcalls to hardware through kernel >Systemcalls to user through a scriptinglanguage_
  • 9. Why Bash? #Not much knowledge required #Combines C-shell, Bourne Shell, … #Free Software #_
  • 10. What the hell is wrong with a GUI? #Nothing >For once in a life-time configurations >Living today is pretty awesome #Everything >When you have to configure 20 PC's the same way >When you don't want to install a demo-version of some proprietary tool >When you want to do things fast_
  • 11. Speaking Bash_
  • 12. Built-in commands &, (( )), ., :, [, [[, alias, bg, bind, break, builtin, caller, case, cd, command, compgen, complete, compopt, continue, coproc, declare, dirs, disown, echo, enable, eval, exec, exit, export, false, fc, fg, for, for, function, getopts, hash, history, if, jobs, kill, let, local, logout, mapfile, bind, printf, pushd, pwd, read, readarray, readonly, return, set, select, shift, shopt, source, suspend, test, time, times, true, typeset, ulimit, umask, unalias, unset, until, variables, wait, while, { cmd; }
  • 13. External commands #Compiled programs #Bash-scripts #Alias-commands #Perl-scripts #Functions #_
  • 14. man-pages #If you don't know how a command works >man command >info command
  • 15. Hello World! On stdout: #echo hello world! On stderr: #echo hello world! >&2 To a file: #echo hello world! > HELLOWORLD To the end of a file: #echo hello world! >> HELLOWORLD
  • 16. Input ###################In script #read a b c #set - Set your $IFS! ###################From CLI #Script.sh < file #Here document: #script.sh <<EOF
  • 17. Scripting Basics #Magic - #!/bin/bash #Add -x to debug #Comments - # #; = EOL # escapes EOL #chmod +x #echo $PATH
  • 18. Expansion #VARIABLE=value >All-caps not needed, just recommended #echo ${VARIABLE} >{} not always needed, but stops problems >$ is necessary #declare -i VARIABLE=value >Specifies variable is an integer
  • 19. Expansion #Command Substitution >$(command) >`command` #Tilde >~ = your home directory >~user = user's home directory #Wildcard globs >man 7 glob
  • 20. Expansion #Prevention > escapes a single special character >“” escapes all but $, ` and >'' escapes all special characters
  • 21. Loops #for VAR in items in list; do commands; done #exit status - $? #test - [ condition ] #while [ test ]; do commands; done #until [ test ]; do commands; done
  • 22. Conditional Statements #Operators >&& >|| #if [ test ]; then commands #elif [ test ]; then commands #else commands #fi
  • 23. Conditional Statements #case VAR in >option) >commands >;; >*) >commands >;; >esac
  • 24. I/O Redirection #Combining 1 and 2 >&> >&>> >2>&1 >>&2 #Channel 0 – STDIN >< >-
  • 25. User Input #Arguments >$1, $2, ${10}, etc. >$* or $@ >$#
  • 26. Bash 4_
  • 27. Bash4 #Associative arrays! #Expansions ~ perl #Coproc #..._
  • 28. Associative Arrays #Declare -A array #array[element]=hello #echo ${array[element]}
  • 29. New expansions Substring #${#:0:1} Case modification #${var^^} #${var^} #${var,} #${var,,}
  • 30. Chopping strings Get the extension of the current script #${0##*.} #${0#*.} (not correct) Get the filename without extension #${0%.*} #${0%%.*} (not correct)
  • 31. Examples
  • 32. Questions #CC BY-SA