Q
Q
Quad_Tree2016-09-25 21:58:00
linux
Quad_Tree, 2016-09-25 21:58:00

Where did I go wrong in the sh script?

Here is the line in the update.sh file:

find -name "*.md" -exec touch time.md.html \; -exec cat theme/header.html >> time.md.html \    ; -exec pandoc -t html {} >> time.md.html \; -exec cat theme/footer.html >> time.md.html \;     -exec cp time.md.html blog/{}.html \; -exec rm time.md.html \;

Now I will describe what it does:
1. Finds all files with the md extension in the current directory and executes several commands on them:
1.1. Creates a temporary file time.md.html
1.2. Writes the content of theme/header.html
to it 1.3. The content of the found md file is converted to html format and written to a temporary file
1.4. And finally writes the content of theme/footer.html
1.5 into it. Next, I copy the generated html page in the form of the time.md.html file to the blog folder with the original file name
1.6. I delete the temporary file time.md.html
As a result, a set of ready-made html pages should appear in the blog folder.
But instead I end up with a bunch of files in the blog folder that contain absolutely nothing and only one html page that contains at least something. Where could I be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daemon23RUS, 2016-09-25
@Daemon23RUS

Replace the last 2 commands with mv (move) and you will see an interesting result. At the output, get 1 file in which all the contents will be sequentially added. and a certain number of errors that No such file or directory. I think that the handle of the remote file is still with find`a Modify the command so that different files are created, and transfer / rename

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question