Create an empty file in all subfolders

I need to extract the archive and create an empty file in each of the folders contained in the archive.

I tried this:

for folder in `ls -d1 */` ; do touch "${folder}/COMPLETE"; done;

It works perfectly until someone creates a folder with a space in its name.

How to do this for all folders with or without spaces?

\ Hugo

+3
source share
2 answers

Instead, you can use find:

find . -type d -exec touch {}/COMPLETE \;
+10
source

don't analyze lswith a loopfor

for folder in */
do
  touch "$folder/COMPLETE"
done
+4
source

Source: https://habr.com/ru/post/1790760/


All Articles