[英]Formatting output for a bash script
The output looks like this output 看起来像这样
bbnum,building,floor,cluster,row,position,namespaces
BBEG,BUILDEG,1,CLUsEG,5,19,namespaceEG
I would like to add spaces throughout, match up the top row with the bottom and delete cluster, row and namespaces (Delete the top and bottom part of the provided list)我想在整个过程中添加空格,将顶行与底部匹配并删除集群、行和命名空间(删除提供的列表的顶部和底部)
Im trying to make it look something like this.我试图让它看起来像这样。 Just trying to make it look neat
只是想让它看起来整洁
bbnum building floor row position
BBEG BUILDEG 1 5 19
Any help would be greatly appreciated!!任何帮助将不胜感激!!
Edit:
remove comma with sed
and try piping your output to column -ts,
command like this:编辑:
用 sed 删除逗号,
然后尝试将 output 输送到column -ts,
命令如下:
$ echo -e "bbnum,building,floor,cluster,row,position,namespaces\nBBEG,BUILDEG,1,CLUsEG,5,19,namespaceEG" | column -ts,
bbnum building floor cluster row position namespaces
BBEG BUILDEG 1 CLUsEG 5 19 namespaceEG
while read; do
printf "%10s %10s %10s %10s\n" $(echo "$REPLY"|cut -d "," --output-delimiter " " -f 1-3,6)
done < yourfile.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.