RHEL6基础三十五之服务器维护基础命令⑤wc、paste

简介:

wc---Word Count

格式:wc [-选项] filename

功能:统计指定文件中的行数、字数、字节数,并将统计结果显示输出。

选项:

默认统计行数、字数、字节数三项,结果中不出现文件名通过管道实现

1
2
3
4
5
6
7
[root@justin ~] # cat /home/passwd
It is not only good to our health, but also to the environment.
There is no CO2 being produced as there are  in  cars. So it is very clean and green.
If you go to work by a bicycle instead of driving, you will get a better chance to get enough exercise.
[root@justin ~] # cat /home/passwd|wc
       3      52     253
[root@justin ~] #
-l  :统计行数;

1
2
3
[root@justin ~] # cat /home/passwd|wc -l
3
[root@justin ~] #
-w  :统计字数。一个字被定义为由空白、跳格或换行字符分隔的字符串;
1
2
3
[root@justin ~] # cat /home/passwd|wc -w
52
[root@justin ~] #

-c 统计字节数;

1
2
3
[root@justin ~] # cat /home/passwd|wc -c
253
[root@justin ~] #

-m  :统计字符数。这个标志不能与 -c 标志一起使用;

1
2
3
[root@justin ~] # cat /home/passwd|wc -m
253
[root@justin ~] #

-L 打印最长行的长度;

1
2
3
[root@justin ~] # cat /home/passwd|wc -L
104
[root@justin ~] #


paste---用于合并文件的列

paste [-s][-d <间隔字符>][--help][--version][文件...]

参数:

-d<间隔字符>或--delimiters=<间隔字符>  用指定的间隔字符取代跳格字符。

-s或--serial  串列进行而非平行处理,将一个文件中的多行数据合并为一行进行显示。

--help  在线帮助。

--version  显示帮助信息。

[文件…] 指定操作的文件路径

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[root@localhost ~] # cat 1.txt 
1 a
[root@localhost ~] # cat 2.txt 
2 b
2 b
[root@localhost ~] # cat 3.txt 
3 c
3 c
3 c
[root@localhost ~] # paste 1.txt 2.txt 3.txt 
1 a    2 b    3 c
     2 b    3 c
         3 c
[root@localhost ~] # paste -d':' 1.txt 2.txt 3.txt 
1 a:2 b:3 c
:2 b:3 c
::3 c     
[root@localhost ~] # paste -s -d ';' 3.txt 
3 c;3 c;3 c
[root@localhost ~] # paste -s -d';' 3.txt 
3 c;3 c;3 c
[root@localhost ~] #




本文转自 justin_peng 51CTO博客,原文链接:http://blog.51cto.com/ityunwei2017/1335496,如需转载请自行联系原作者
相关文章
|
2月前
|
Linux Shell 网络安全
【Shell 命令集合 网络通讯 】Linux 与SMB服务器进行交互 smbclient命令 使用指南
【Shell 命令集合 网络通讯 】Linux 与SMB服务器进行交互 smbclient命令 使用指南
64 1
|
8月前
|
Shell Linux 应用服务中间件
ABAP 面试题:如何使用 ABAP 编程语言的 System CALL 接口,直接执行 ABAP 服务器所在操作系统的 shell 命令?
ABAP 面试题:如何使用 ABAP 编程语言的 System CALL 接口,直接执行 ABAP 服务器所在操作系统的 shell 命令?
115 0
|
4月前
|
中间件 Linux
linux查看服务器系统版本命令
linux查看服务器系统版本命令
66 0
|
6月前
|
Cloud Native 网络安全 Go
SSH连接服务器后执行多条命令
SSH连接服务器后执行多条命令
|
2月前
|
网络协议 安全 Shell
【Shell 命令集合 系统设置 】Linux 从远程时间服务器获取当前日期和时间 rdate命令 使用指南
【Shell 命令集合 系统设置 】Linux 从远程时间服务器获取当前日期和时间 rdate命令 使用指南
46 0
|
2月前
|
Shell Linux 网络安全
【Shell 命令集合 网络通讯 】Linux 管理Apache HTTP服务器 httpd命令 使用指南
【Shell 命令集合 网络通讯 】Linux 管理Apache HTTP服务器 httpd命令 使用指南
36 0
|
2月前
|
Shell Linux Apache
【Shell 命令集合 网络通讯 】Linux 管理Apache HTTP服务器 apachectl命令 使用教程
【Shell 命令集合 网络通讯 】Linux 管理Apache HTTP服务器 apachectl命令 使用教程
168 1
|
6月前
|
网络安全 数据安全/隐私保护
用smtp发送邮件,语法错误,无法识别命令。 服务器响应为:Authentication is re
用smtp发送邮件,语法错误,无法识别命令。 服务器响应为:Authentication is re
98 0
|
2月前
|
Linux Shell 调度
PBS任务脚本模板及常用服务器PBS命令介绍
【2月更文挑战第21天】本文介绍在Linux服务器中,通过PBS(Portable Batch System)作业管理系统脚本的方式,提交任务到服务器队列,并执行任务的方法~
189 4
PBS任务脚本模板及常用服务器PBS命令介绍
|
2月前
|
Linux
一个能够在 ABAP 服务器执行 linux 命令的小工具
一个能够在 ABAP 服务器执行 linux 命令的小工具
19 0

热门文章

最新文章