Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a file in each folder?

Tags:

linux

I want to create an index.html file in each folder of my project in linux.

index.html should contain some sample code.

How can I create a file in single command?

like image 954
whiterose Avatar asked Apr 18 '11 10:04

whiterose


2 Answers

find . -type d -exec touch {}/index.html \;

This'll create an index.html in . and all subdirectories.

like image 130
Erik Avatar answered Oct 08 '22 18:10

Erik


cd /project_dir && find . -type d -exec touch \{\}/index.htm \;

HTH

like image 37
Zsolt Botykai Avatar answered Oct 08 '22 18:10

Zsolt Botykai