linux ps cut,linux按列分割cut

linux按列分割cut

按列获取数据,例如ps命令中,我想获取UID这一列。使用ps | cut -c 44-47便可以。

Shell代码

$ ps

PID    PPID    PGID     WINPID  TTY  UID    STIME COMMAND

5204       1    5204       5204  con  500 11:53:47 /bin/sh

4716    5204    4716       2724  con  500 11:54:05 /bin/ps

www.2cto.com

Shell代码

$ ps | cut  -c 44-47

UID

500

500

500

cut有几个常用参数,-c 指定开始字符位置, -b 指定开始字节位置, -f 指定开始分割节点位置。

cut --help

Sehll代码

$ cut --help

Usage: cut [OPTION]... [FILE]...

Print selected parts of lines from each FILE to standard output.

-b, --bytes=LIST        output only these bytes

-c, --characters=LIST   output only these characters

-d, --delimiter=DELIM   use DELIM instead of TAB for field delimiter

-f, --fields=LIST       output only these fields

-n                      (ignored)

-s, --only-delimited    do not print lines not containing delimiters

--output-delimiter=STRING  use STRING as the output delimiter

the default is to use the input delimiter

--help              display this help and exit

--version           output version information and exit

www.2cto.com

Use one, and only one of -b, -c or -f.  Each LIST is made up of one

range, or many ranges separated by commas.  Each range is one of:

N     N'th byte, character or field, counted from 1

N-    from N'th byte, character or field, to end of line

N-M   from N'th to M'th (included) byte, character or field

-M    from first to M'th (included) byte, character or field

With no FILE, or when FILE is -, read standard input.

Report bugs to .

http://www.dengb.com/Linuxjc/552892.htmlwww.dengb.comtruehttp://www.dengb.com/Linuxjc/552892.htmlTechArticlelinux按列分割cut 按列获取数据,例如ps命令中,我想获取UID这一列。使用ps | cut -c 44-47便可以。 Shell代码 $ ps PID PPID PGID WINPID TTY UID STIME COM...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值