sed:在字符串之间添加新行

问题描述 投票:0回答:1

我使用 ls + sed 的组合来制作文件夹中的图像列表,并创建特定格式的输出文件,其中每行由空行等分隔

ls ${blocks}/*png | sed 's/^/![caption](/;s/$/)\n/' > ${blocks}/out

问题是,尽管 最后 sed 不会在每个字符串后添加“新行”。

对于大量 png 图像,使用 find 而不是 ls 会更好吗?

bash sed ls
1个回答
0
投票

你可以尝试:

find "$blocks" -type f -name '*.png' -printf "![caption](%p)\n\n"
© www.soinside.com 2019 - 2024. All rights reserved.