I have a directory where there are subdirectories which have numbers as directories. For example I have a parent directory test
now I have some subdirectories like 1
,2
,3
,4
,5
,6
,7
.
Now I have a local exported variable like export a=3
. I want to delete directories that are above or equal to $a
but below or equal to $a+2
, So I want to delete directories 3
, 4
,5
.
Also if I don't know the least number directory and I want to delete everything below or equal to $a
so the directories 1
,2
,3
gets deleted. How can I achieve this?
I tried rm -rf {$a..$($a+3)}
and rm -rf {<$a}
, it didn't work, I tried so many other things but not successful.
$a
, and you do calculating lower and upper both based on the$a
, so what do mean when you are saying "Also if I don't know the least number directory and I want to delete everything below or equal to <$a
"?zsh
-based solution?