[英]What is wrong with my markdown to pdf bash script?
I am trying to make a script that makes a pdf in a specific directory using pandoc and markdown. 我试图制作一个脚本,使用pandoc和markdown在特定目录中创建pdf。 The command I am trying to run works when I run it in a shell, but not when I run it through the script.
我尝试运行的命令在外壳程序中运行时有效,但在脚本中运行时却无效。 I have tried using the --verbose flag to get some debug output, but pandoc complains about not recognizing the option.
我尝试使用--verbose标志获取一些调试输出,但是pandoc抱怨无法识别该选项。
Here is my script so far. 到目前为止,这是我的脚本。
#!/usr/bin/env bash
IN_FILE=$1
OUT_DIR=$2
CURRENT_DATE="$(date +%d%m%Y)"
SUBSTRING=${IN_FILE%.*}
if [[ ${IN_FILE: -3} == ".md" ]]; then
OUT_FILE=${SUBSTRING}-${CURRENT_DATE}.pdf
pandoc -r markdown -o ${NOTES_DIR}/${OUT_DIR}/${OUT_FILE}
else
echo "Wrong file type. Needs to be .md"
fi
Turns out I had forgotten to specify the in file in the call to pandoc. 原来我忘了在调用pandoc时指定in文件。 I just did not see it.
我只是没有看到它。
Here is the updated script, works fine now. 这是更新的脚本,现在可以正常工作。
#!/usr/bin/env bash
IN_FILE=$1
OUT_DIR=$2
CURRENT_DATE="$(date +%d%m%Y)"
SUBSTRING=${IN_FILE%.*}
if [[ ${IN_FILE: -3} == ".md" ]]; then
OUT_FILE=${SUBSTRING}-${CURRENT_DATE}.pdf
pandoc -r markdown -o ${NOTES_DIR}/${OUT_DIR}/${OUT_FILE} ${IN_FILE}
else
echo "Wrong file type. Needs to be .md"
fi
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.