linux命令column,Linux column命令详解(每日一令之二十一)
发布日期:2021-06-24 12:34:28 浏览次数:2 分类:技术文章

本文共 2032 字,大约阅读时间需要 6 分钟。

功能介绍:

格式化输出

使用放法:NAME

column - columnate lists

SYNOPSIS

column [-tx] [-c columns] [-s sep] [file ...]

DESCRIPTION

The column utility formats its input into multiple columns. Rows are filled before columns. Input is taken from file operands, or, by default, from the standard

input. Empty lines are ignored.

The options are as follows:

-c Output is formatted for a display columns wide.

-s Specify a set of characters to be used to delimit columns for the -t option.

-t Determine the number of columns the input contains and create a table. Columns are delimited with whitespace, by default, or with the characters supplied

using the -s option. Useful for pretty-printing displays.

-x Fill columns before filling rows.

Column exits 0 on success, >0 if an error occurred.

实例[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选项:

我以为-s选项是输出分隔符,比如上面,我是用如下命令:[root@uyhd000225 ms]# mount |column -s '@' -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)

[root@uyhd000225 ms]#

我以为他会输出以@为分隔符,但是没有安装我的期望输出

man column没有详细说明使用方法,info column也没有:

google发现他是输出分隔符,使用方法如下[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

转载地址:https://blog.csdn.net/weixin_32767591/article/details/116611612 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:centos linux7 开启桌面命令,centos7如何在桌面打开终端
下一篇:linux 进程2,linux下的进程(2)

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月01日 06时48分47秒