1 / 13

Project: Bash Shell System Programming I

Project: Bash Shell System Programming I. Alex Jamieson, Ezequiel Jackson, & Chris Haley Team B Amazon Apprentice Program  Center for Info. Assurance Education (CIAE) (NSA/DHS CAE-CDE). Agenda. Introduce team Discuss scope of project Exercises overview What we learned.

rdonna
Télécharger la présentation

Project: Bash Shell System Programming I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Project: Bash Shell System Programming I Alex Jamieson, Ezequiel Jackson, & Chris Haley Team BAmazon Apprentice Program  Center for Info. Assurance Education (CIAE) (NSA/DHS CAE-CDE)

  2. Agenda • Introduce team • Discuss scope of project • Exercises overview • What we learned

  3. Alex Jamieson - Exercises • Chapter 1 Exercise 1 • Create a main directory and two subdirectories • /home/ubuntu/bpl • /home/ubuntu/bpl/bin • /home/ubuntu/bpl/scripts • Using the mkdir command • Chapter 3 Exercise 2 • Check whether a file exists • Use a while loop and nested if loop • Continues to prompt user until user input is a valid file

  4. Alex Jamieson - Exercises • Chapter 4 Exercise 1 • Question: How many arguments are there on this command line?   sa $# $(date "+%Y %m %d") John\ Doe • Answer: 3 • sa is a command and $# expands the number of arguments • $(date "+%Y %m %d"), John\, and Doe are arguments • Chapter 6 Exercise 1 • IFS=.   vs    ${1//./} • IFS (Internal Field Separator) - By default is the IFS is a space • Parameter Expansion - ${var//pattern/string}

  5. Alex Jamieson - Exercises • Chapter 7 Exercise 3 • Created a function called palindrome • Retrieved user input • Ran function against user input

  6. Ezequiel Jackson – Exercises •year=$( date +%Y ) •month=$( date +%m )  •day=$( date +%d ) •hour=$( date +%H )  •minute=$( date +%M ) •second=$( date +%S )  This would give you an incorrect date, and you are writing date 6 times when you only need to write it once. 5.2: For Single Variable names are reasonable: when used, within the space up to three lines. Index variables when iterating over a list e.g. I,n,k. Equations:  var prices = [50, 20, 30]; var discount = .9; _.map(prices, function (p) {return p * discount;}); // -> [45, 18, 27]

  7. Ezequiel Jackson – Exercises 1.2 & 7.2 exercises

  8. Ezequiel Jackson – Exercises

  9. Chris Haley – Exercises • Chapter 2 Exercise 2 • Generate numbers using $RANDOM • Output numbers to a file and a variable • Chapter 3 Exercise 1 • Question: Enter a number between 20 and 30 and ask again if invalid • Until loop with nested if statements

  10. Chris Haley – Exercises • Chapter 5 Exercise 3 • Extract 168 using parameter expansion -- var=192.168.0.123 • echo ${var:4:3}

  11. Chris Haley - Exercises  • Chapter 6 Exercise 2 • Add ability to verify a variable is a valid name to max3() • Chapter 7 Exercise 4 • Write two functions: ltrim & rtrim • Regular expresions • [[ "$ltrim" =~ ^' '*([characters])(.*) ]] • [[ "$rtrim" =~ ^(' '*)(.*)([a-z,A-Z,0-9])' '*$ ]]

  12. What we learned • Regular expressions • Linux system programming • Bash syntax and commands

  13. Key references • Johnson, C. F. A. & Varma, J. (2015). Pro Bash Programming: Scripting the GNU/Linux Shell Second Edition. Apress. (9781484201220)

More Related