Linux教程

[ Linux ] column 简明用法

本文主要是介绍[ Linux ] column 简明用法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

https://www.cnblogs.com/yeungchie/

options

  • -c
    指定每一行输出的宽度。
  • -t
    判断列来输出,对齐所有列。
    主要用到的就是这个选项。
  • -s
    指定分隔符,默认为空白符。
  • -o
    指定用于对齐列填充的符号,默认为空白符。

cat

看一下原文本。

yeung@eda7 Linux ~/tmp 
> cat pin.list | sort
Address[0] Metal3,pin 133.175:159.92
Address[1] Metal3,pin 112.38:159.92
Address[2] Metal3,pin 70.775:159.92
Address[3] Metal3,pin 41.655:159.92
DataIn[0] Metal3,pin 66.615:159.92
DataIn[1] Metal3,pin 37.495:159.92
DataIn[2] Metal3,pin 122.88:159.92
DataIn[3] Metal3,pin 95.74:159.92
DataOut[0] Metal3,pin 45.815:159.92
DataOut[1] Metal3,pin 79.095:159.92
DataOut[2] Metal3,pin 104.055:159.92
DataOut[3] Metal3,pin 62.46:159.92
MemReq Metal3,pin 108.215:159.92
RdWrBar Metal3,pin 87.415:159.92
clock Metal3,pin 74.935:159.92

column -c

指定行宽度。

yeung@eda7 Linux ~/tmp 
> cat pin.list | sort | column -c 80
Address[0] Metal3,pin 133.175:159.92    DataOut[0] Metal3,pin 45.815:159.92
Address[1] Metal3,pin 112.38:159.92     DataOut[1] Metal3,pin 79.095:159.92
Address[2] Metal3,pin 70.775:159.92     DataOut[2] Metal3,pin 104.055:159.92
Address[3] Metal3,pin 41.655:159.92     DataOut[3] Metal3,pin 62.46:159.92
DataIn[0] Metal3,pin 66.615:159.92      MemReq Metal3,pin 108.215:159.92
DataIn[1] Metal3,pin 37.495:159.92      RdWrBar Metal3,pin 87.415:159.92
DataIn[2] Metal3,pin 122.88:159.92      clock Metal3,pin 74.935:159.92

column -t

对齐列。

yeung@eda7 Linux ~/tmp 
> cat pin.list | sort | column -t
Address[0]  Metal3,pin  133.175:159.92
Address[1]  Metal3,pin  112.38:159.92
Address[2]  Metal3,pin  70.775:159.92
Address[3]  Metal3,pin  41.655:159.92
DataIn[0]   Metal3,pin  66.615:159.92
DataIn[1]   Metal3,pin  37.495:159.92
DataIn[2]   Metal3,pin  122.88:159.92
DataIn[3]   Metal3,pin  95.74:159.92
DataOut[0]  Metal3,pin  45.815:159.92
DataOut[1]  Metal3,pin  79.095:159.92
DataOut[2]  Metal3,pin  104.055:159.92
DataOut[3]  Metal3,pin  62.46:159.92
MemReq      Metal3,pin  108.215:159.92
RdWrBar     Metal3,pin  87.415:159.92
clock       Metal3,pin  74.935:159.92

column -s

指定分隔符。

yeung@eda7 Linux ~/tmp 
> cat pin.list | sort | column -t -s' ,:'
Address[0]  Metal3  pin  133.175  159.92
Address[1]  Metal3  pin  112.38   159.92
Address[2]  Metal3  pin  70.775   159.92
Address[3]  Metal3  pin  41.655   159.92
DataIn[0]   Metal3  pin  66.615   159.92
DataIn[1]   Metal3  pin  37.495   159.92
DataIn[2]   Metal3  pin  122.88   159.92
DataIn[3]   Metal3  pin  95.74    159.92
DataOut[0]  Metal3  pin  45.815   159.92
DataOut[1]  Metal3  pin  79.095   159.92
DataOut[2]  Metal3  pin  104.055  159.92
DataOut[3]  Metal3  pin  62.46    159.92
MemReq      Metal3  pin  108.215  159.92
RdWrBar     Metal3  pin  87.415   159.92
clock       Metal3  pin  74.935   159.92

column -o

指定符号填充。

yeung@eda7 Linux ~/tmp 
> cat pin.list | sort | column -t -s' ,:' -o','
Address[0],Metal3,pin,133.175,159.92
Address[1],Metal3,pin,112.38 ,159.92
Address[2],Metal3,pin,70.775 ,159.92
Address[3],Metal3,pin,41.655 ,159.92
DataIn[0] ,Metal3,pin,66.615 ,159.92
DataIn[1] ,Metal3,pin,37.495 ,159.92
DataIn[2] ,Metal3,pin,122.88 ,159.92
DataIn[3] ,Metal3,pin,95.74  ,159.92
DataOut[0],Metal3,pin,45.815 ,159.92
DataOut[1],Metal3,pin,79.095 ,159.92
DataOut[2],Metal3,pin,104.055,159.92
DataOut[3],Metal3,pin,62.46  ,159.92
MemReq    ,Metal3,pin,108.215,159.92
RdWrBar   ,Metal3,pin,87.415 ,159.92
clock     ,Metal3,pin,74.935 ,159.92
这篇关于[ Linux ] column 简明用法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!