I have a directory /var/opt/gitlab/backups
with the following permissions:
[user@localhost ~]$ sudo ls -la /var/opt/gitlab/backups
total 1316296
drwx------. 2 git root 63 1月 21 21:44 .
drwxr-xr-x. 21 root root 4096 1月 21 21:39 ..
-rw-------. 1 git git 1347880960 1月 21 21:44 1642819457_2022_01_21_14.1.2-ee_gitlab_backup.tar
Now the following command does not remove anything
sudo rm -rf /var/opt/gitlab/backups/*
While the following command removes the directory and everything inside
sudo rm -rf /var/opt/gitlab/backups/
Also the following command will remove the specific file
sudo rm -rf /var/opt/gitlab/backups/1642819457_2022_01_21_14.1.2-ee_gitlab_backup.tar
It's only the file wildcard way does not work (which unfortunately is what I want)
However what I want is only removing the files inside and not removing the directory. I suspect it's because of the permission settings but changing the permissions is not an option for me. The directory owner and permissions are set automatically by a third-party software and I would like not to mess around.
Is there any way to achieve the "removing all files inside the directory but not the directory itself" effect?
r
from the-rf
? – Abdelhakim AKODADI Jan 22 '22 at 03:33