paste - merge lines of files
-d, --delimiters=LIST
reuse characters from LIST instead of TABs
-s, --serial
paste one file at a time instead of in parallel
- With no FILE, or when FILE is -, read standard input.
-d 与 -s 分别是两个参数
-d 用来指定分隔符 -s 默认是用tab做分隔符的。用来表示先将一个文件合并成一行在合并两个文件的行,变成两行。而“-”表示当从标准输入输入。
例子:
[useputty_login@PC_IN_LAN ~]$cat a
aaa
ccc
eee
ggg
[useputty_login@PC_IN_LAN ~]$cat b
bbb
ddd
fff
hhh
[useputty_login@PC_IN_LAN ~]$paste a b(默认是tab做分隔符的 如下)
aaa bbb
ccc ddd
eee fff
ggg hhh
[useputty_login@PC_IN_LAN ~]$paste -d":" a b(用-d 指定分隔符为:)
aaa:bbb
ccc:ddd
eee:fff
ggg:hhh
[useputty_login@PC_IN_LAN ~]$paste -d: -s a b(用-d 指定分隔符为:先将a合成一行b合成一行,)
aaa:ccc:eee:ggg
bbb:ddd:fff:hhh
[useputty_login@PC_IN_LAN ~]$paste -d: -s a - > c (从标准输入读取 合并后重定向到c)
this is a test!
[useputty_login@PC_IN_LAN ~]$cat c(查看c)
aaa:ccc:eee:ggg
this is a test!
》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
cut - remove sections from each line of files
-c, --characters=LIST
select only these characters
-d, --delimiter=DELIM
use DELIM instead of TAB for field delimiter
-f, --fields=LIST
select only these fields; also print any line that contains no
delimiter character, unless the -s option is specified
-s, --only-delimited
do not print lines not containing delimiters
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.
cut 命令格式:cut 选项 参数 文件
-d 指定分隔符默认是tab
-c 指定按字符来抽取指定字符
-f 指定按字段抽取一个或多哥字段
-s
N 表示第N个字符/字段
N-M 表示从第N个字符/字段到第M个字符/字段
N- 表示从第N个字符/字段到最后
-N 表示从第N个字符/字段之前
[useputty_login@PC_IN_LAN ~]$cat a
This is a test!
just for fun!
run on the bank!
in the red!
[useputty_login@PC_IN_LAN ~]$cut -c 5 a(从输出看出空格算一个字符因为分隔符是tab 输出了第五个符)
o
h
[useputty_login@PC_IN_LAN ~]$cut -c 6-8 a (输出第六个到第八个)
is
for
n t
e r
[useputty_login@PC_IN_LAN ~]$cut -d" " -f 2 a(用-d 指定分隔符为空格 -f表示操作对象是字段取2字段)
is
for
on
the
[useputty_login@PC_IN_LAN ~]$cut -d" " -f 2- a(取 2到最后一个字段)
is a test!
for fun!
on the bank!
the red!
[useputty_login@PC_IN_LAN ~]$cut -d" " -f 1 -s a(表示去除对没有指定分隔符的行后操作)
This
just
run
阅读(1718) | 评论(0) | 转发(0) |