How can I remove all dirs that start with a prefix, So I have something like this
- xyzdirblah
- xyzdir2
- xyzdir3
- xyzdir4
- ..more
want to do via adb shell , android
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
rmis the command to delete things.-rmeans recursively delete directories.-fmeans don’t ask questions, and don’t complain.-rfmeans both of those things together.xyzdir*expands to the names of files that start with “xyzdir” (including directory names, since in Unix-like systems — including Android — directories are really just a special kind of file.)If there are nondirectory files with the same prefix, like “xyzdir.txt”, which you don’t want to remove, you have to be more careful:
This loops over every file-or-directory with a name starting with “xyzdir” (the
for i inpart), checks whether it is a directory (the[ -d $i ]part), and if so (the&&part), removes it recursively (therm -rf $ipart).