我使用 ls + sed 的组合来制作文件夹中的图像列表,并创建特定格式的输出文件,其中每行由空行等分隔
ls ${blocks}/*png | sed 's/^/![caption](/;s/$/)\n/' > ${blocks}/out
问题是,尽管 最后 sed 不会在每个字符串后添加“新行”。
对于大量 png 图像,使用 find 而不是 ls 会更好吗?
你可以尝试:
find "$blocks" -type f -name '*.png' -printf "![caption](%p)\n\n"