From 23d332b98476b041592b5d41f56165179aa8c6bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20de=20Favereau=20de=20Jeneret?= <jerome.defavereau@uclouvain.be> Date: Wed, 25 Sep 2024 12:25:46 +0000 Subject: [PATCH] added exercise 5 --- Bash.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Bash.md b/Bash.md index 2b6f1dd..fd11aa4 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 --- -- GitLab