运维 第二单元作业

第二单元作业

  • 用命令和正则表达式按照要求建立文件
  • 用一条命令建立12个文件WESTOS_classX_linuxY(X的数值范围为 1-2 , Y 的数值范围为 1-6 )
    这些文件都包含在root用户桌面的study目录中

[root@localhost Desktop]$ mkdir study
[[root@localhost Desktop]$ cd study/
[root@localhost study]$ touch WESTOX_class{1…2}_linux{1…6}
[root@localhost study]$ ls
WESTOX_class1_linux1 WESTOX_class1_linux5 WESTOX_class2_linux3
WESTOX_class1_linux2 WESTOX_class1_linux6 WESTOX_class2_linux4
WESTOX_class1_linux3 WESTOX_class2_linux1 WESTOX_class2_linux5
WESTOX_class1_linux4 WESTOX_class2_linux2 WESTOX_class2_linux6

  • 用一条命令建立8个文件redhat_versionX(X的范围为1-8)
    redhat_virsionX这些文件都包含在/tmp目录中的VERSION中

[root@localhost Desktop]# mkdir /tmp/VERSION/
[root@localhost Desktop]# cd /tmp/VERSION/
[root@localhost VERSION]# touch redhat_version{1…8}
[root@localhost VERSION]# ls
redhat_version1 redhat_version3 redhat_version5 redhat_version7
redhat_version2 redhat_version4 redhat_version6 redhat_version8

  • 管理刚才新建立的文件要求如下
  • 用一条命令把redhat_versionX中的带有奇数的文件复制到桌面SINGLE

[root@localhost VERSION]# mkdir /root/Desktop/SINGLE/
[root@localhost VERSION]# cp redhat_version{1,3,5,7} /root/Desktop/SINGLE/
[root@localhost VERSION]# cd /root/Desktop/SINGLE/
[root@localhost SINGLE]# ls
redhat_version1 redhat_version3 redhat_version5 redhat_version7

  • 用一条命令把redhat_versionX中的带有偶数的文件复制到 /DOUBLE中

[root@localhost VERSION]# mkdir /root/Desktop/DOUBLE/
[root@localhost VERSION]# cp redhat_version{2,4,6,8} /root/Desktop/DOUBLE/
[root@localhost DOUBLE]# ls
redhat_version2 redhat_version4 redhat_version6 redhat_version8

  • 用一条命令把WESTOS_classX_linuxY中class1 的文件移动到当前用户中的 CLASS1 中

[root@localhost DOUBLE]# cd /root/Desktop/study/
[root@localhost study]# cp WESTOS_class1_linux* /root/Desktop/CLASS1

[root@localhost study]# cd /root/Desktop/CLASS1
[root@localhost CLASS1]# ls
WESTOS_class1_linux1 WESTOS_class1_linux3 WESTOS_class1_linux5
WESTOS_class1_linux2 WESTOS_class1_linux4 WESTOS_class1_linux6

  • 用一条命令把WESTO_classX_linuxY 中class2 的文件移动到当前用户桌面的CLASS2 中

[root@localhost DOUBLE]# cd /root/Desktop/study/
[root@localhost study]# cp WESTOS_class2_linux* /root/Desktop/CLASS2
[root@localhost study]# cd /root/Desktop/CLASS2
[root@localhost CLASS2]# ls
WESTOS_class2_linux1 WESTOS_class2_linux3 WESTOS_class2_linux5
WESTOS_class2_linux2 WESTOS_class2_linux4 WESTOS_class2_linux6

  • 备份 /etc目录中所有带有名字带有数字并且以.conf结尾的文件爱你到桌面上的confdir 中

[root@localhost etc]# cp -r [[:digif:]].conf /root/Desktop/confdir/

  • 删掉刚才建立或者备份的所有文件

[root@localhost Desktop]# rm -fr *
[root@localhost Desktop]# rm -fr /tmp/VERSION/

猜你喜欢

转载自blog.csdn.net/qq_38840475/article/details/82874544