bash - How to echo content to each file in subfolders in Linux? -
i've directory structure this:
/posts | | posts/page1 -- index.html posts/page2 -- index.html posts/page{3..100} -- index.html
i've figured out how create 100 different page#
directories, , i've touched index.html
each of them. however, need echo basic html each of index.html
files in each of page#
directories.
f in `find . -type d`; echo "hello" >> f; done
but echo 100 hello
s file named f
f in `find . -type d`; echo "hello"; done
simply echos hello
100 times.
and
for f in `find . -type d`; echo "hello" >> index.html; done
just echos hello
100 times within posts/index.html
anyway, i'm @ loss how this. how without having manually it? theoretically open each folder in sublime , copy html ctrl+v + ctrl+s + ctrl+w
each instance, there's gotta easier way this.
you need use $f
refer items in find
result, instead of f
. , also, include /index.html
path:
for f in $(find . -type d); echo "hello" >> $f/index.html; done ^^^^^^^^^^^^^
in current code redirecting constant f
, while want refer variable name $f
. reason of using $f
instead of f
.
Comments
Post a Comment