sed および seq コマンドの問題

sed および seq コマンドの問題

この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

おすすめ記事