0

I'm looking for a command or bash script that will create an index.html file in every directory and subdirectory starting at the current directory. I would like it to prompt to overwrite so I don't delete a good index.html file.

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by cfajohnson
0
$ export INDEXFILE=/path/to/index/file/index.html
$ find . -type d -exec cp -i ${INDEXFILE} '{}' \;

That copies ${INDEXFILE} interactively to every directory found below the execution point.

N.B. Not tested.

0

This doesn't prompt to overwrite; it does nothing in directories already containing index.html:

ndx=index.html
find . -type d | while read dir
do
  (
    cd "$dir" &&
     [ -s "$ndx" ] || mkindex > "$ndx" ## where mkindex is a script to create index file
  )
done
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.