lec08 - Lecture 8 Bourne shell scripting(I Have you started...

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

View Full Document Right Arrow Icon
Lecture 8: Bourne shell scripting (I) Have you started HW3 yet?
Image of page 1

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

View Full Document Right Arrow Icon
Exit status Every command run returns an exit status 0 = success Anything else = failed, somehow $? = exit status of last command grep -q – doesn't print anything Only useful for exit status What if grep didn't have -q ? Argument to Java's System.exit C's return from main()
Image of page 2
Signals What kill really does: Send a “signal” to a process or job Default = SIGTERM (TERMinate; please quit) 9 = SIGKILL (KILL; extreme prejudice) CTRL-C = SIGINT (INTerrupt) yes > /dev/null (CTRL-C) $? = 130 = 128 + 2; 2 = SIGINT yes > /dev/null; kill -9 $? = 137 = 128 + 9; 9 = SIGKILL
Image of page 3

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

View Full Document Right Arrow Icon
Using exit status; if/else if grep -q purple colors then echo found purple else echo did not find it fi Newlines are important!
Image of page 4
If/else in general if command1 then command2 elif command3 then command4 ... else command5 fi
Image of page 5

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

View Full Document Right Arrow Icon
Semicolons Multiple commands on the same line – separate with semicolon Semicolon can substitute for a newline (but only for Bourne shell) if grep -q purple colors; then echo Yes; else echo No; fi
Image of page 6
Image of page 7
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