我在 Mac OS X 中工作,我在 sed 中尝试了几个命令来替换制表符和文件名。
for f in *.txt; do sed -i '' -e "s/$/\t$f/g" $f; done
for f in *.txt; do sed -i '' -e "s/$/[CTR+V][CTR+I]$f/g" $f; done
(https://stackoverflow.com/questions/6363328/replacing-with-tab-using-sed)
但我关注的是角色而不是标签。有什么修改建议吗?
答案1
尝试:
for f in ./*.txt; do
sed -i '' -e "s/$/$(printf '\t')$f/g" "$f"
done