Reputation: 25986
When I do the following find
overrides index.html
where I would have expected it would just append its results.
echo "<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head></body>" > index.html
find . -name "*.html" -exec echo "<a href=\"{}\">{}</a><br/>" \; >> index.html
It is suppose to find all html files and create an index of them.
Does anyone how to do this, ideally without using temp files?
Upvotes: 1
Views: 931
Reputation: 16202
You have to escape all " characters in echo.
echo "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/></head></body>" > index.html
find . -name "*.html" -exec echo "<a href=\"{}\">{}</a><br/>" \; >> index.html
Upvotes: 2
Reputation: 785108
Problem is in your echo line, echo line should be:
echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head></body>' > index.html
You have "
inside your text and in your echo command boundary as well.
Upvotes: 2