Friday, May 3, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 4111  / 3 Years ago, mon, may 10, 2021, 7:15:17

i run the following command line to remove all files/dirs in directory :



       cd /home/abdennour/android/

rm -rf *


the architecture of this directory is as following :



   /home/abdennour/android/
/home/abdennour/android/documents/
/home/abdennour/android/documents/medialib/
/home/abdennour/android/documents/preview/
/home/abdennour/android/fixtures/
/home/abdennour/android/images/
/home/abdennour/android/images/hard/
/home/abdennour/android/images/mlibrary/
/home/abdennour/android/images/mlibrary/thumbs/
/home/abdennour/android/js/
.....


i want to remove all with excluding the following directories :



  /home/abdennour/android/documents/
/home/abdennour/android/images/mlibrary/

More From » command-line

 Answers
3

You can use GLOBIGNORE environment variable. Suppose that you want to delete everithing except /home/abdennour/android/documents/ and /home/abdennour/android/images/mlibrary/, then you can do the following:



cd /home/abdennour/android/
export GLOBIGNORE="documents:images"
rm -rf *
cd images
export GLOBIGNORE="mlibrary"
rm -rf *
export GLOBIGNORE=""

[#28799] Tuesday, May 11, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
wenceslockro

Total Points: 494
Total Questions: 127
Total Answers: 97

Location: Chad
Member since Mon, Dec 5, 2022
1 Year ago
;