以下是我的档案。我试图在输出之间保持恒定的宽度,以便所有管道符号都低于另一个,它看起来像表格式。我怎样才能做到这一点?我邮寄输出时也需要格式相同。
cat file.txt
name,score card,ID
Jack,Available,YES
Jen,NA,NO
Jerry,Available,YES
Padula,NA,YES
Mackenzi,NA,NO
sed 's/,/\t|\t/g' c.txt
name | score card | ID
Jack | Available | YES
Jen | NA | NO
Jerry | Available | YES
Padula | NA | YES
Mackenzi | NA | NO
==I want==
name | score card | ID
Jack | Available | YES
Jen | NA | NO
Jerry | Available | YES
Padula | NA | YES
Mackenzi | NA | NO
答案 0 :(得分:5)
$ sed 's/,/,|,/g' file | column -t -s,
name | score card | ID
Jack | Available | YES
Jen | NA | NO
Jerry | Available | YES
Padula | NA | YES
Mackenzi | NA | NO
答案 1 :(得分:0)
如果您希望使用awk
存档,
awk -F"," '{printf "%-10s%s%-10s%s%-10s\n", $1,OFS,$2,OFS,$3}' OFS="|" file.txt