Linux命令——column
参考:Viewing Linux output in columns
功能
column命令把他的输入格式化多列显示。输入可以是文件,也可以是标准输入。
列优先,从左到右
显示的时候首先填满最左列,然后右列,顺序如下
1 4 7 10
2 5 8 11
3 6 9 12
测试文件
$ cat RR
I've been working on the railroad
All the live long day
I've been working on the railroad
Just to pass the time away Can't you hear the whistle blowing
Rise up so early in the morn
Can't you hear the whistle blowing
Dinah, blow your horn Dinah, won't you blow
Dinah, won't you blow
Dinah, won't you blow your horn
Dinah, won't you blow,
Dinah, won't you blow,
Dinah, won't you blow your horn
显示结果
$ column RR
I've been working on the railroad Dinah, blow your horn
All the live long day Dinah, won't you blow
I've been working on the railroad Dinah, won't you blow
Just to pass the time away Dinah, won't you blow your horn
Can't you hear the whistle blowing Dinah, won't you blow,
Rise up so early in the morn Dinah, won't you blow,
Can't you hear the whistle blowing Dinah, won't you blow your horn
行优先,从上到下
使用-x参数
$ cat RR
I've been working on the railroad
All the live long day
I've been working on the railroad
Just to pass the time away Can't you hear the whistle blowing
Rise up so early in the morn
Can't you hear the whistle blowing
Dinah, blow your horn Dinah, won't you blow
Dinah, won't you blow
Dinah, won't you blow your horn
Dinah, won't you blow,
Dinah, won't you blow,
Dinah, won't you blow your horn
$ column -x RR
I've been working on the railroad All the live long day
I've been working on the railroad Just to pass the time away
Can't you hear the whistle blowing Rise up so early in the morn
Can't you hear the whistle blowing Dinah, blow your horn
Dinah won't you blow Dinah won't you blow
Dinah, won't you blow your horn Dinah, won't you blow,
Dinah, won't you blow, Dinah, won't you blow your horn
保留空行
使用-e参数
$ cat RR
I've been working on the railroad
All the live long day
I've been working on the railroad
Just to pass the time away Can't you hear the whistle blowing
Rise up so early in the morn
Can't you hear the whistle blowing
Dinah, blow your horn Dinah, won't you blow
Dinah, won't you blow
Dinah, won't you blow your horn
Dinah, won't you blow,
Dinah, won't you blow,
Dinah, won't you blow your horn
$ column -e RR
I've been working on the railroad Dinah, blow your horn
All the live long day
I've been working on the railroad Dinah, won't you blow
Just to pass the time away Dinah, won't you blow
Dinah, won't you blow your horn
Can't you hear the whistle blowing Dinah, won't you blow,
Rise up so early in the morn Dinah, won't you blow,
Can't you hear the whistle blowing Dinah, won't you blow your horn
指定分隔符
默认的分隔符是空格,可以使用-s指定分隔符
$ cat abc
a:b:c:d:e
$ column -t -s: abc
a b c d e
把行创建出列表
上面指定分隔符的时候有个参数-t。-t用于根据-s指定的分隔符(默认为空格)将一行创建出几列。
这个参数经常用于查看mount输出。mount输出内容比较杂,每一行包含很多信息,信息之间以空格分隔
[root@localhost bin]# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=2001952k,nr_inodes=,mode=)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=,mode=,ptmxmode=)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,net_prio,net_cls)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,devices)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,cpuset)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,hugetlb)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,memory)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,perf_event)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,freezer)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,blkio)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,cpuacct,cpu)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,pids)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mapper/centos-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd- on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=,pgrp=,timeout=,minproto=,maxproto=,direct,pipe_ino=)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
/dev/mapper/centos-home on /home type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
tmpfs on /run/user/ type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=402844k,mode=)
[root@localhost bin]# mount | column -t
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=2001952k,nr_inodes=,mode=)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=,mode=,ptmxmode=)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,net_prio,net_cls)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,devices)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,cpuset)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,hugetlb)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,memory)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,perf_event)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,freezer)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,blkio)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,cpuacct,cpu)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,pids)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mapper/centos-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd- on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=,pgrp=,timeout=,minproto=,maxproto=,direct,pipe_ino=)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
/dev/mapper/centos-home on /home type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
tmpfs on /run/user/ type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=402844k,mode=)
智障的设定
想想使用这个命令的场景,多数时候是因为输出结果一列显示太长了,多列显示能短一点。column虽然可以多列显示,但是你却不能控制他到底显示几列。这个设定相当智障。前面说到column显示规则,列优先,从左到右。他能显示的最大列数与你终端窗口允许显示最大列数有关,最左列显示不完才会再显示一列,以此类推。
pr解决了这个问题,参考:Linux命令——pr
不管你显示几列,每列宽度一样,如果某一行长度超过终端窗口宽度一半以上,那么你永远只能得到一列输出。更智障的设定
使用-c参数,你可以指定一列有多宽,不过貌似很少用得上。
Linux命令——column的更多相关文章
- Linux命令——pr
参考:Linux命令——column 前言 接触这个命令的初衷是我想把一个很长的单列输出设置成多列输出,奈何column的分列输出机制太智障,直到我发现了pr 参数 pr -# 输出指定的列数. -t ...
- 开发过程中常用的Linux命令
做Java开发好几年了,部署JavaWeb到服务器上,一般都选择Linux,Linux作为服务器真是不二之选,高性能,只要熟悉Linux,操作快捷,效率很高. 总结一下工作中常用的Linux命令备忘: ...
- Linux命令行技巧
Linux命令行技巧 命令 描述 • apropos whatis 显示和word相关的命令. 参见线程安全 • man -t man | ps2pdf - > man.pdf 生成一个PDF格 ...
- Linux 命令大全之Red Hat 7常用命令总结二
Linux 命令大全之RedHat7常用命令笔记... ----------------------------------------------------- 征服Linux从终端开始 ----- ...
- Linux 命令行
Linux 命令笔记 一.目录/文件 1.1 目录文件日常操作 . -> 当前目录 .. -> 上一级目录 .file/.dir -> 隐藏文件/文件夹 [ls] 查看指定目录文件 ...
- linux 命令中英文对照,收集
linux 命令中英文对照,收集 linux 命令英文全文 Is Linux CLI case-sensitive? The answer is, yes. If you try to run L ...
- (5)ps详解 (每周一个linux命令系列)
(5)ps详解 (每周一个linux命令系列) linux命令 ps详解 引言:今天的命令是用来看进程状态的ps命令 ps 我们先看man ps ps - report a snapshot of t ...
- (4)top详解 (每周一个linux命令系列)
(4)top详解 (每周一个linux命令系列) linux命令 top详解 引言:今天的命令是用来看cpu信息的top top 我们先看man top top - display Linux pro ...
- (3)lscpu详解 (每周一个linux命令系列)
(3)lscpu详解 (每周一个linux命令系列) linux命令 lscpu详解 引言:今天的命令是用来看cpu信息的lscpu lscpu 我们先看man lscpu display infor ...
随机推荐
- 【ARTS】01_46_左耳听风-201900923~201900929
ARTS: Algrothm: leetcode算法题目 Review: 阅读并且点评一篇英文技术文章 Tip/Techni: 学习一个技术技巧 Share: 分享一篇有观点和思考的技术文章 Algo ...
- 使用 LVS 实现负载均衡原理及安装配置详解(课堂随笔)
一.负载均衡LVS基本介绍 LB集群的架构和原理很简单,就是当用户的请求过来时,会直接分发到Director Server上,然后它把用户的请求根据设置好的调度算法,智能均衡地分发到后端真正服务器(r ...
- 第八章 跨语言服务治理方案 Service Mesh
8.1 Service Mesh 概述 新兴的下一代微服务架构,被称为下一代微服务,同时也是云原生技术栈的代表技术之一. 8.1.1 Service Mesh的由来 从2016年到2018年,serv ...
- 图解JavaScript闭包面试题
由于最近在学习关于闭包相关的知识,并且闭包这个知识点让我有点搞不太清楚其具体的定义,所以在网上也查阅了很多大佬的讲解和对闭包的一个定义. 最后感觉还是MDN上的说法感觉比较好理解一些,对闭包还是不太理 ...
- Head First Design Patterns HeadFirst 设计模式
OO原则是我们的目标,而设计模式是我们的做法. 策略模式 (Strategy) 在软件开发上,一直不变的真理是"change".不管软件设计的多好,一段时间之后,总是要成长与改变, ...
- Jira强制退出时(如意外停电)再启动报Locked错误的几个解决办法
查看jira_home的路径在/opt/atlassian/jira/atlassian-jira/WEB-INF/classes/jira-application.properties文件中查看 方 ...
- PHP如何访问数据库集群
一般常见的有三种做法, 1,自动判断sql是否为读,来选择数据库的连接: 实例化php DB类的时候,需要一次连接两台服务器,然后根据slq选择不同的连接,举个例子: $link_w = mysql_ ...
- [转帖]Linux下主机间文件传输命令
Linux下主机间文件传输命令 https://yq.aliyun.com/articles/53631?spm=a2c4e.11155435.0.0.580ce8ef4Q9uzs SCP命令: ...
- java当中JDBC当中请给出一个sql server的stored procedure例子
3.sql server的stored procedure例子: import java.sql.*;public class StoredProc0 {public static void main ...
- 【坑】前后端分离开发中 跨域问题以及前台不带cookie的问题
文章目录 前言 跨域问题 cookie问题 拦截器导致的跨域问题 后记 前言 场景一: 前台哒哒哒的点击页面,发送请求,但是后台服务器总是没有回应,后台接口虽打了断点,但是根本进不到断点处: 前端:我 ...