Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating empty file in all subfolders

Tags:

bash

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

I tried this:

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

works just perfect till someone creates a folder with a space in its name.

How can I do this for all folders with or without spaces in their names?

\Hugo

like image 857
Hugo Avatar asked Feb 08 '11 16:02

Hugo


People also ask

How do I empty files in a folder?

Select the item you want to delete. Press and hold the Shift key, then press the Delete key on your keyboard.

What is an empty directory?

Here, an empty directory means the directory is present without any files or subdirectories. We can define a directory as a collection of files and subdirectories, a directory may have data or not contain no data. The non-empty directory means the directory with files or subdirectories.

Do empty folders have size?

In Windows filesystems, size of a directory is the sum t otal of all files (and folders) in it. So, an empty directory has size zero.


1 Answers

You can use find instead:

find . -type d -exec touch {}/COMPLETE \;
like image 190
dogbane Avatar answered Nov 10 '22 19:11

dogbane