# BASH: rmdir dans un script

**URL:** <https://www.debian-fr.org/t/bash-rmdir-dans-un-script/90241>\
**Category:** Programmation\
**Created:** [Juillet 31, 2024, 2:07 UTC](https://www.debian-fr.org/t/bash-rmdir-dans-un-script/90241 "2024-07-31T14:07:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josephtux](https://www.debian-fr.org/user_avatar/www.debian-fr.org/josephtux/32/3985_2.png) [@josephtux](https://www.debian-fr.org/u/josephtux)\
**Post date:** [Juillet 31, 2024, 2:07 UTC](https://www.debian-fr.org/t/bash-rmdir-dans-un-script/90241/1 "2024-07-31T14:07:50Z")

</div>

Bonjour,

dans un script, celui qui a créé les répertoires visés, la commande suivante renvoie un échec, alors que la même commande - sauf erreur de ma part! - fonctionne:

`rmdir --ignore-fail-on-non-empty "${USBDIR}/BKP/*"`

La variable USBDIR est:

```
USBDIR='/media/eric/Tosh2Tbleu2ext4'

```

et la commande

```
 echo "${USBDIR}/BKP/*"  

```

renvoie: `/media/eric/Tosh2Tbleu2ext4/BKP/*`

le répertoire «&nbsp;${USBDIR}/BKP/&nbsp;» contient:

```
$ls -l /media/eric/Tosh2Tbleu2ext4/BKP/
total 8
drwxr-xr-x 2 eric eric 4096 31 juil. 15:54 24_07_31-15h54m
drwxr-xr-x 2 eric eric 4096 31 juil. 15:55 24_07_31-15h55m

```

et la commande suivante fonctionne:

`$rmdir --ignore-fail-on-non-empty /media/eric/Tosh2Tbleu2ext4/BKP/*`

Où est l’erreur ?

merci pour votre attention

---

<div class="post-metadata">

**Author:** ![Zargos](https://www.debian-fr.org/user_avatar/www.debian-fr.org/zargos/32/10889_2.png) [@Zargos](https://www.debian-fr.org/u/Zargos)\
**Post date:** [Juillet 31, 2024, 2:29 UTC](https://www.debian-fr.org/t/bash-rmdir-dans-un-script/90241/2 "2024-07-31T14:29:10Z")

</div>

> [@josephtux](#):
>
> rmdir --ignore-fail-on-non-empty «&nbsp;${USBDIR}/BKP/\*&nbsp;»

pas besoins de guillemet, car sinon c’est une chaîne et ta variable n’est pas interprétée.

---

<div class="post-metadata">

**Author:** ![josephtux](https://www.debian-fr.org/user_avatar/www.debian-fr.org/josephtux/32/3985_2.png) [@josephtux](https://www.debian-fr.org/u/josephtux)\
**Post date:** [Juillet 31, 2024, 2:36 UTC](https://www.debian-fr.org/t/bash-rmdir-dans-un-script/90241/3 "2024-07-31T14:36:10Z")

</div>

Merci Zargos,  
j’avoue ne toujours pas maîtriser cette notion de bash et l’oublier (je programme trés rarement)
