tongsiying

阅读|运动|自律

0%

column

前言

以将文本结果转换为整齐的表格,上下对齐

1. 命令格式

1
tr [选项]... SET1 [SET2]

2. 命令参数

1
2
3
4
5
参数:
-c 字符数 指定显示的列宽
-s 分隔符 使用-t选项时,指定分隔符(允许指定多个分隔符)
-t 判断输入行的列数来创建一个表。分隔符是使用在-s中指定的字符。如果没有指定分隔符,默认是空格
-x 更改排列顺序(左→右)。默认的顺序为(上→下)

3.范例

-t举例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@uyhd000225 ~]# mount
/dev/hda1 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/xvdb1 on /data type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
[root@uyhd000225 ~]# mount |column -t
/dev/hda1   on  /                         type  ext3         (rw)
proc        on  /proc                     type  proc         (rw)
sysfs       on  /sys                      type  sysfs        (rw)
devpts      on  /dev/pts                  type  devpts       (rw,gid=5,mode=620)
tmpfs       on  /dev/shm                  type  tmpfs        (rw)
/dev/xvdb1  on  /data                     type  ext3         (rw)
none        on  /proc/sys/fs/binfmt_misc  type  binfmt_misc  (rw)

-s举例:

1
2
3
4
5
6
7
8
[root@uyhd000225 testDir]# cat testcolumn
Jackie | 18 | male
Helen | 20 | female
Daniel Liu | 23 | male
[root@uyhd000225 testDir]# cat testcolumn | column -s '|' -t
Jackie        18    male
Helen         20    female
Daniel Liu    23    male

引用:
http://linux.51yip.com/search/column

赞赏一下吧~