-1

在创建 shell 脚本期间,我遇到了一个问题。实际上我有一个包含以下信息的文件。

<FLATFILE CODEPAGE ="UTF-8" CONSECDELIMITERSASONE ="NO" DELIMITED ="YES" DELIMITERS =";" ESCAPE_CHARACTER ="" KEEPESCAPECHAR ="NO" LINESEQUENTIAL ="NO" MULTIDELIMITERSASAND ="NO" NULLCHARTYPE ="ASCII" NULL_CHARACTER ="*" PADBYTES ="1" QUOTE_CHARACTER ="NONE" REPEATABLE ="NO" ROWDELIMITER ="10" SHIFTSENSITIVEDATA ="NO" SKIPROWS ="1" STRIPTRAILINGBLANKS ="NO"/>

我想修改上面的文件,如下所示。

FLATFILE CODEPAGE ="UTF-8" 
CONSECDELIMITERSASONE ="NO" 
DELIMITED ="YES" 
DELIMITERS =";" 
ESCAPE_CHARACTER ="" 
KEEPESCAPECHAR ="NO" 
LINESEQUENTIAL ="NO" 
MULTIDELIMITERSASAND ="NO" 
NULLCHARTYPE ="ASCII" 
NULL_CHARACTER ="*" 
PADBYTES ="1" 
QUOTE_CHARACTER ="NONE" 
REPEATABLE ="NO" 
ROWDELIMITER ="10" 
SHIFTSENSITIVEDATA ="NO" 
SKIPROWS ="1" 
STRIPTRAILINGBLANKS ="NO"

谁能帮我解决这个问题。

4

3 回答 3

2
sed 's:<\|\(/>\)::g;s:\(=[^ ]\+\) :\1\n:g' INPUTFILE

可能对你有用。首先它替换标签右括号。="WHATEVER"然后用值和换行符替换每次出现的值 ( )。它将一直有效,直到您在这些"s 之间留出空间。

于 2013-06-07T06:12:04.333 回答
0

尝试:

sed 's/^<//;s/" /"\n/g;s/\/>//' _file_
于 2013-06-07T06:47:43.457 回答
0

尝试这个:

sed 's/ =/=/g' | tr " " "\n" | sed -e 's/<//' -e 's/>//' -e 's/\///'
于 2013-06-07T06:55:20.097 回答