---
# System prepended metadata

title: LF - Exercises 8

---

# LF - Exercises 8

##### 1. What is the result of running below script? Explain lines 8, 9 and 10

#!/usr/bin/bash 
function quit {
   exit
 }
 function hello {
   echo Hello!
 }
 hello
 quit
echo “an important message”

Explanation: Line 8, is going to call to `hello` function, that prints "Hello!", then line 9 is going to call to `quit` function, that stops the execution, that means line ten never is executed.

##### 2. Write a script that looks for txt files in a specified directory; list and count them; and maybe just count or list them depending on a provided option.

`
#!/usr/bin/bash
function listTxtFiles {
  echo "Getting list from $3..."
  find $1 -name "*.txt"
}
function countTxtFiles {
  echo "Counting files..."
  ls $1/*.txt | wc -l
}

listTxtFiles $1
countTxtFiles $1
exit
`
![](https://i.imgur.com/MAyWlrN.png)

