在创建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"
任何人都可以帮助我。
答案 0 :(得分:2)
sed 's:<\|\(/>\)::g;s:\(=[^ ]\+\) :\1\n:g' INPUTFILE
可能会为你工作。首先,它取代了标签关闭括号。然后用值和换行符替换值(="WHATEVER"
)的每个匹配项。它会一直有效,直到你在"
s。
答案 1 :(得分:0)
尝试:
sed 's/^<//;s/" /"\n/g;s/\/>//' _file_
答案 2 :(得分:0)
试试这个:
sed 's/ =/=/g' | tr " " "\n" | sed -e 's/<//' -e 's/>//' -e 's/\///'