linux - How do I recursively visit and delete all files in a particular folder which has spaces in sh? -


i using

p=` ls -l -p $mydir | egrep '^d' | awk '{print $9}'  

for getting folders , then

for dirs in ${p} 

for recursively opening folders. works fine folder name without spaces, folder names spaces, second part of folder name selected seperate folder.

to iterate on directories under $mydir,

 find "$mydir" -type d |  while read dir;     printf '%s\n' "deleting files in <$dir>"     rm -f "$dir"/*  done 

note must double quote dir variable when using prevent shell performing word-splitting @ spaces.

skipping $mydir if don't need left exercise.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -