linux按列分割cut
按列获取数据,例如ps命令中,我想获取UID这一列。使用ps|cut-c44-47便可以。
$ 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
$ ps | cut -c 44-47 UID 500 500 500
cut有几个常用参数,-c指定开始字符位置,-b指定开始字节位置,-f指定开始分割节点位置。
cut--help
$ 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 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 <[email protected]>.
相关推荐
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20