1
我有看起來像這樣的用sed來天真的文本文件轉換成XML
BOOK|100004
TRAN|A
ANAM|Alberta
TNAM|The School Act; the School Assessment Act. The Tax Recovery Act. The School Grants Act. The School Attendance Act and General Regulations of the Department of Education
PBLS|King's Printer
SUB1|Alberta, Canada, Canadian Prairies, NOISBN
我需要創建一個具有這種格式的XML文件中的記錄文本文件,
<BOOK>100004</BOOK>
<TRAN>A</TRAN>
<first 4 chars> text data </ first 4 chars again>
我認爲我幾乎沒有像這樣一個sed命令,
$sed 's#([:alpha:]\{4\})\|(*)#\<\1\>\2<\/\1\>#g'
除非我得到這個錯誤: - sed: -e expression #1, char 41: invalid reference \1 on
S'命令的[R HS'
任何sed專家都想將我推向啓發路徑?
太感謝你了! –