day 3.4

day3.4

文件命令管理

去重命令

# 去重命令 :uniq
注意:去重内容,必须是连续的行,必须要配合sort先排序,再去重,去重不会修改源文件。
选项:
-C: 统计

举例:
[root@localhost ~]# cat info.txt 
1
2
1
1
111
11
22
22
2
33
3

[root@localhost ~]# uniq info.txt 
1
2
1
111
11
22
2
33
3

[root@localhost ~]# uniq  -c info.txt 
      1 1
      1 2
      2 1
      1 111
      1 11
      2 22
      1 2
      1 33
      1 3

文件截取命令

# 文件截取命令
cut:截取

选项:
-d:指定分隔符(默认没有分隔符)
-f:去列,选择要打印的内容
-c:按照字符来取内容

# 举例
创建:
[root@localhost ~]# cat info.txt 

name:wc oid 88 wx  11111111
name:cjk oid 23232 wx 2323432423

[root@localhost ~]# cut -d ' ' -f 3 info.txt 

88
23232

[root@localhost ~]# cut -c 3-5 info.txt 

me:
me:

文件统计命令

# 文件统计命令
wc:统计文件行数、单词数量、字符数量

选项:
-l:统计行数
-w:统计单词数
-c:统计字符数

举例:
[root@localhost ~]# wc /etc/services 
 11176    61033    670293     /etc/services
文件行数 单词数量    字符数量   文件名

[root@localhost ~]# wc -l info.txt 
3 info.txt

[root@localhost ~]# wc -c info.txt 
62 info.txt

[root@localhost ~]# wc -w info.txt 
10 info.txt

[root@localhost ~]# wc -wlc info.txt 
 3 10 62 info.txt

posted @   Gabydawei  阅读(26)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 2 本地部署DeepSeek模型构建本地知识库+联网搜索详细步骤
点击右上角即可分享
微信分享提示