Create a file in a directory shell -


i have directory named "dir" in there html file , folders named 01 02 03 ... 10. want create folder "dir", in each folder file page01.html folder 01 , page02.html dir 02 etc ..

i have tried:

for in `ls -a * /`; touch page$i.html done 

but not create me files in directories.

thank you

to create file pagex.html each directory x, can use:

for dir in */   touch "$dir/page$dir.html" done 

this safer , less redundant version of for dir in `ls -d */`, should never used has problems various types of special characters.

if have other directories, can limit ones 2 digits name:

for dir in [0-9][0-9]/   touch "$dir/page$dir.html" done 

Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

amazon web services - Installing MobileFirst 7.0 server on AWS -

Non Unique Username with ASP.Net Identity 2.0 -