lec09 - CS114 Lecture 9 More shell scripting HW3 due...

Info icon This preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
CS114: Lecture 9 More shell scripting HW3 due Wednesday...
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
A note on mountpoints What disk is /lib on? Mount doesn't show an entry for /lib But it must be on SOME disk... Perl is /usr/bin/perl ; mount has an entry for /usr , but not /usr/bin . So where is Perl?
Image of page 2
Comments and newlines # to end of line is totally ignored (like // in Java or C++) # is the “comment character” in many scripting languages sh, csh, Perl, Python, Tcl, ruby, ... Why? \ at end of line continues to next line (useful for looooong pipes)
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Math in shell scripts expr 1 + 3 Prints 4 expr 2 \* 4 Prints 8 Spaces are important! expr 1+ 3 – error expr 1+3 Prints 1+3 (it's a string)
Image of page 4
Bourne shell scripting: While loops #!/bin/sh i="" while [ "$i" \!= xxxxx ]; do echo Iteration $i i=x$i done How many loops? Why “$i” above? until ... do .. done (just like while but backwards)
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
case – many tests at once #!/bin/sh case $1 in [a-zA-Z]*) echo "$1 starts with a letter" ;; [0-9]*) echo "$1 starts with a number" ;; *) echo "$1 starts with a punctuation mark" ;; esac
Image of page 6
case in general case word in pattern ) command ;; pattern ) command
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern