我有类似csv文件的东西,其中字段分隔符是"@".
ID @名称@姓@时代@职业@地址
1254343123@John@Smith@24@Engineer@Washington 23@Alexander@Kristofferson-Brown@Economic Advisor@Kent ...
我想把它转换成人类可读的东西,如:
1254343123 John Smith 24 Engineer Washington 23 Alexander Kristofferson-Brown 35 Economic Advisor Kent
...每个栏目都以特定角色出现.
我尝试了一些利用TAB-size值的东西,并在该字段中添加了几个TAB:
sed -e "{/@[^@]\{32,\}@/s/@\([^@]*\)@/\t\1\t/g};{/@[^@]\{24,31\}@/s/@\([^@]*\)@/\t\1\t/g};{/@[^@]\{16,23\}@/s/@\([^@]*\)@/\t\1\t\t/g};{/@[^@]\{8,15\}@/s/@\([^@]*\)@/\t\1\t\t/g};{/@[^@]\{2,7\}@/s/@\([^@]*\)@/\t\1\t\t\t/g}"
Run Code Online (Sandbox Code Playgroud)
......在所有情况下都不起作用.
有人可以给我一个暗示如何继续吗?
PS:我的意图是主要使用sed(一个单行)或者如果sed只是没有削减它,awk就可以了.