Linux的基础命令

文件的建立&拷贝&改名

在当前目录下建立文件aaa.txt,将文件aaa.txt拷贝到/tmp这个目录下,并改名为 bbb.txt

[c-long@localhost test]$ ls
abc  a.txt  b.html  b.txt  Hello.java
[c-long@localhost test]$ touch aaa.txt
[c-long@localhost test]$ ls
aaa.txt  abc  a.txt  b.html  b.txt  Hello.java
[c-long@localhost test]$ cp aaa.txt /tmp/bbb.txt
[c-long@localhost test]$ ls /tmp/
anaconda.log
bbb.txt
hsperfdata_c-long
hsperfdata_root
ifcfg.log

在任何目录下回到用户主目录(家)

[c-long@localhost test]$ cd
[c-long@localhost ~]$ 

当前目录打印

打印当前目录(隐藏文件也显示)

[c-long@localhost ~]$ ls -a
.              .bash_profile  .dbus          .mozilla  视频  音乐
..             .bashrc        .esd_auth      .viminfo  图片  桌面
.bash_history  .cache         .ICEauthority  公共      文档
.bash_logout   .config        .local         模板      下载


打包压缩文件

创建5个文件分别是 1.txt 2.txt 3.txt 4.txt 5.txt,压缩这5个文件,压缩包的名字是my.tar

[c-long@localhost test]$ touch 1.txt
[c-long@localhost test]$ touch 2.txt
[c-long@localhost test]$ touch 3.txt
[c-long@localhost test]$ touch 4.txt
[c-long@localhost test]$ touch 5.txt
[c-long@localhost test]$ ls
1.txt  3.txt  5.txt    abc    b.html  Hello.java
2.txt  4.txt  aaa.txt  a.txt  b.txt
[c-long@localhost test]$ tar zcvf my.tar 1.txt 2.txt 3.txt 4.txt 5.txt
1.txt
2.txt
3.txt
4.txt
5.txt
[c-long@localhost test]$ ls
1.txt  3.txt  5.txt    abc    b.html  Hello.java
2.txt  4.txt  aaa.txt  a.txt  b.txt   my.tar

查看文件最后10行

[c-long@localhost test]$ tail -10 a.txt
11
12
13
14
15
16
17
18
19
20

将指定文件中所有的a ,替换成b

[c-long@localhost test]$ cat aaa.txt
ababbba
babaaab
ababbab
aaabbba
accaaca
[c-long@localhost test]$ vim aaa.txt

:%s /a/b/g

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值