My top-level directory is
data includes several directories and these directories have sub-directories. I need to remove all files and directories inside
data/ except several files in some directories.
For example, data includes the directories
101. I just want to keep
b.txt files in
d.txt files in
101/ while removing all other files and directories in
. ├── 100 │ ├── a.txt │ ├── b.txt │ ├── c.txt │ └── d.txt └── 101 ├── a.txt ├── b.txt ├── c.txt └── d.txt
rm -rf !(a.txt|b.txt) command but I can't apply this command for each directory automatically.