
이 bash 스크립트를 사용하십시오
seq=$(seq 3)
sed -i "i ${seq}" input.txt
나는 얻다:
sed: -e expression #1, char 6: unknown command: `
'
그러나 아래 스크립트는 작동합니다.
sed -i "i 1 2 3" input.txt
왜?
답변1
man sed
:
i \ text Insert text, which has each embedded newline preceded by a backslash.
출력에 "전례 없는" 줄 바꿈이 있습니다( seq
공백이 있는 축어적 레코드와 달리).1 2 3