输入文件有两个记录和三个字段,第二个属性包含换行符。我想用双引号将每个字段值括起来。
100|Alert created becuase of high volume.
Money withdrawan more 5000.
Try to access acccount from unathorised devíce|2019-01-24
200|Minimum amount not avialable in your account.
Last time deposited amonut month ago|2019-01-24
"100"|"Alert created becuase of high volume.
Money withdrawan more 5000.
Try to access acccount from unathorised devíce"|"2019-01-24"
"200"|"Minimum amount not avialable in your account.
Last time deposited amonut month ago"|"2019-01-24"
您可以尝试使用此awk:
awk -F'\n' '!f{$1="\""$1;f=1}{f=f+gsub("[|]","\"|\"")}f==3{$0=$0"\"";f=0}1' infile
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句