Embercode
✕
The TerminalQuick quiz

Script basics

9 questions. Covers Loops and conditionals in scripts.

Questions 1 to 5 of 9

  1. 1. Put these steps in the order you do them to write and run the first script in the lesson.

    Use the arrows to put the steps in order.

    1. 1.Run it with bash hello.sh
    2. 2.Read the printed line hello Asha
    3. 3.Add the lines name="Asha" and echo "hello $name"
    4. 4.Create hello.sh and make its first line #!/usr/bin/env bash
  2. 2. Put these lines of a file-reading loop in the order they must appear in the script.

    Use the arrows to put the steps in order.

    1. 1.done < fruit.txt
    2. 2.while IFS= read -r line; do
    3. 3.echo "line: $line"
  3. 3. Put these steps in the order they happen when an if test uses grep -q.

    Use the arrows to put the steps in order.

    1. 1.The if reads exit code 0 as a true test
    2. 2.The then block runs and prints found banana
    3. 3.grep finds a match and exits with code 0
    4. 4.grep -q banana fruit.txt searches the file and prints nothing
  4. 4. This script should print hello Asha. What is wrong with it? ``bash #!/usr/bin/env bash name = "Asha" echo "hello $name" ``
  5. 5. This script is meant to say found when the file my notes.txt exists. Run it and it prints an error line before no. ``bash #!/usr/bin/env bash f="my notes.txt" if [ -f $f ]; then echo found; else echo no; fi `` What is the bug?

2 question(s) left on this page.