Week 13 Lecture.docx - Week 13 Lecture Practice 11 Q1/bin/bash Word1=”counter” Word2=”clockwise” echo “The combined word is $word1$word2”

Week 13 Lecture.docx - Week 13 Lecture Practice 11...

This preview shows page 1 - 3 out of 3 pages.

Week 13 Lecture Practice 11 Q1. #!/bin/bash Word1=”counter” Word2=”clockwise” echo “The combined word is: $word1$word2” Chmod u+x output: The combined word is: counterclockwise If use $word11$word2 no word 11 so prints: clockwise If ${word1}1$word2 counter1clockwise. The 1 is just a string If ${word1} hello ${word2} counter hello clockwise Q2. #!/bin/bash echo “result1: $1” echo “result2: $2” echo “result3: $3” echo “result 4:” echo “$*” ./q2 apple orange banana Output: result1: apple; result 2: orange; result 3: banana; result 4: (nothing), apple orange banana (which is $*) Q3. #!/bin/bash for x do if [ $x -gt 25 ] then echo “Hello” else echo “Goodbye”
Image of page 1
fi echo $x done echo $* echo $# On exam – show exactly what is on the screen ./q3 45 13 does loop twice; prints: Hello 45 Goodbye 13 45 13 2 ON THE EXAM – LONGER SCRIPT; LOOPING WITH IF AND WHILE STATEMENTS Q4. #!/bin/bash echo $* (prints all on one line) | tr ‘ ‘ ‘\n ./q4 hello john how are you today Hello John
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 3 pages?

  • Fall '10
  • michaelhedenreich

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

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes