diff --git a/Bash.md b/Bash.md index 2b6f1ddba4dc1bc655a7a2e249c0b5f94b721d05..fd11aa4d079e1c2ec260a376bbb550a95923e4de 100644 --- a/Bash.md +++ b/Bash.md @@ -914,12 +914,12 @@ print_something Mars # Hands-on exercise -1. Write a script called `exercise_5.sh` expecting **2 arguments**. If not exactly two arguments are provided, exit with an error and show a "usage" message to the user. -2. Write a function taking a **folder path** and an **extension** as arguments and giving the list of matching files to the user -<!-- 3. Imagine you are running jobs taking data from two folders, each with a dedicated extension. Use the two arguments of the script as the name of the two folders and **get the two lists of files**. -4. Since your work needs to read these files, **check that all files can be read**. If some files cannot be read, display their name to the user--> - -<!-- Créer un petit exercice raisonnable--> +1. Write a script called `exercise_5.sh` expecting **2 arguments**. If not exactly two arguments are provided: + * Echo an error message + * Exit with a non-zero error code +2. Write a function taking a **folder path** (e.g `/home/ucl/elic/xxxx`) and an **extension** (e.g `py`) as arguments +3. Use the `ls` command to list the files in the given path having with the given extension. Write this list to a file called `files_found.txt`. +4. Bonus : if there are no files, Exit with a non-zero error code ---