在文字檔頭加入字串? - Linux

Table of Contents

※ 引述《garyzyg (garyzyg)》之銘言:
: ※ 引述《HDav (高畫質AV)》之銘言:
: : 請問要怎麼在一票文字檔開頭中加入特定字串
: : 比如說 01.txt 02.txt 03.txt 的檔頭要加入 ABC 這字串
: : 謝謝
: 改檔名:
: $ rename '' ABC 0?.txt
: 改檔案:
: $ sed -e '1i ABC' -i 0?.txt

$ sed -e '1i ABC' -i 0?.txt
sed: 1: "1i ABC
": command i expects \ followed by text

--

All Comments

Connor avatarConnor2008-11-23
那是因為 sed 版本有點舊.
Delia avatarDelia2008-11-27
$ sed -e '1i \ABC' -i 0?.txt