初识Linux(4)

本文介绍了Linux命令行中常用工具如cat,tac,rev,vimd,head,tail以及wc的基本用法,包括文件查看、逆序输出、行数统计等操作。
摘要由CSDN通过智能技术生成

cat查看:

[root@localhost test]# cat a
1
2
3



[root@localhost test]# cat -s a
1
2
3
[root@localhost test]# cat -b a
     1	1
     2	2
     3	3



tac逆着输出:

[root@localhost test]# printf "1\n2\n3\n4\n"|tac
4
3
2
1

rev 同一行逆着输出:

[root@localhost test]# printf "1 2 3 4"|tac
1 2 3 4[root@localhost test]# 

vim d:下列代码都是对此进行修改

aaaaaaaaaaaa
bbbbbbbbbbbb
cccccccccccc
12344566
21312asdasdffsa
asdasd12eqwdas
dsadas12eqwd
asdsad21
abc sda dwdf
sadas sad asd
21ed 12d1 2ed 1d1
111 111 111
12 23 123 412

head 用法:

[root@localhost test]# head -n 3 ./d
aaaaaaaaaaaa
bbbbbbbbbbbb
cccccccccccc
[root@localhost test]# head -c 4 ./d
aaaa

类似的tail用法:

[root@localhost test]# tail -c 4 ./d
412
[root@localhost test]# tail -n 4 ./d
sadas sad asd
21ed 12d1 2ed 1d1
111 111 111
12 23 123 412

查第三行:

[root@localhost test]# head -n 3 ./d | tail -n 1
cccccccccccc

替换:

[root@localhost test]# cat d |tr a 1
111111111111
bbbbbbbbbbbb
cccccccccccc
12344566
213121sd1sdffs1
1sd1sd12eqwd1s
ds1d1s12eqwd
1sds1d21
1bc sd1 dwdf 
s1d1s s1d 1sd
21ed 12d1 2ed 1d1
111 111 111
12 23 123 412

wc用法:

  • -l:统计行数

  • -w:统计单词个数

  • -c:统计字节数

[root@localhost test]# wc -l d
13 d
[root@localhost test]# wc -w d
25 d
[root@localhost test]# wc -c d
173 d

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值