Linux初学练习
1.用命令和正则表达式按照要求建立文件*)用一条命令建立12个文件WESTOS_classX_linuxY(X的数值范围为1-2,Y的数值范围为1-6)
*)这些文件都包含在root用户桌面的study目录中
# cd /root
# ls
anaconda-ks.cfgDocumentsMusic Public Videos
Desktop DownloadsPicturesTemplates
# cd Desktop/
# cd study/
bash: cd: study/: No such file or directory
# mkdir study
# ls
9.200 9.21 hehe~ study westos
9.200~9.21~hello.exeUntitled Folderwestos~
# cd study/
# touch WESTOS_classX{1..2}_linuxY{1..6}
# ls
WESTOS_classX1_linuxY1WESTOS_classX1_linuxY5WESTOS_classX2_linuxY3
WESTOS_classX1_linuxY2WESTOS_classX1_linuxY6WESTOS_classX2_linuxY4
WESTOS_classX1_linuxY3WESTOS_classX2_linuxY1WESTOS_classX2_linuxY5
WESTOS_classX1_linuxY4WESTOS_classX2_linuxY2WESTOS_classX2_linuxY6
*)用一条命令建立8个文件redhat_versionX(x的范围为1-8)
*)redhat_virsionX这些文件都包含在/mnt目录中的VERSION中
# touch redhat_versionX{1..8}
# ls
9.200 hehe~ redhat_versionX3redhat_versionX7westos
9.200~hello.exe redhat_versionX4redhat_versionX8westos~
9.21 redhat_versionX1redhat_versionX5study
9.21~ redhat_versionX2redhat_versionX6Untitled Folder
# mv redhat_version* /mnt/VERSION
mv: target ‘/mnt/VERSION’ is not a directory
# cd /home
# ls
student
# cd /mnt
# mkdir VERSION
# cd Desktop
bash: cd: Desktop: No such file or directory
# cd /root/Desktop/
# mv redhat_versionX* /mnt/VERSION/
# cd /mnt/VERSION/
# ls
redhat_versionX1redhat_versionX3redhat_versionX5redhat_versionX7
redhat_versionX2redhat_versionX4redhat_versionX6redhat_versionX8
2.管理刚才新建立的文件要求如下
*)用一条命令把redhat_versionX中的带有奇数的文件复制到桌面的SINGLE中
# cp /mnt/VERSION/redhat_versionX{1,3,5,7,9} SINGLE
# cd SINGLE/
# ls
redhat_versionX1redhat_versionX3redhat_versionX5redhat_versionX7
*)用一条命令把redhat_versionX中的带偶数数的文件复制到/DOUBLE中
# cd ..
# mkdir DOUBLE
# ls
9.200 9.21 DOUBLEhello.exestudy westos
9.200~9.21~hehe~ SINGLE Untitled Folderwestos~
# cp /mnt/VERSION/redhat_versionX{2,4,6,8} DOUBLE/
# cd DOUBLE/
# ls
redhat_versionX2redhat_versionX4redhat_versionX6redhat_versionX8
#
*)用一条命令把WESTOS_classX_linuxY中class1的文件移动到当前用户桌面的CLASS1中
这部分要注意移动文件要将study(即WESTOS_class1_linuxY所在位置)作为当前位置。
# mv WESTOS_classX1_linuxY{1..6} /root/Desktop/CLASS1
# ls
WESTOS_classX2_linuxY1WESTOS_classX2_linuxY3WESTOS_classX2_linuxY5
WESTOS_classX2_linuxY2WESTOS_classX2_linuxY4WESTOS_classX2_linuxY6
*)用一条命令把WESTOS_classX_linuxY中class2的文件移动到当前用户桌面的CLASS2中
# mv WESTOS_classX2_linuxY{1..6} /root/Desktop/CLASS2
# cd ..
# cd CLASS2
# ls
WESTOS_classX2_linuxY1WESTOS_classX2_linuxY3WESTOS_classX2_linuxY5
WESTOS_classX2_linuxY2WESTOS_classX2_linuxY4WESTOS_classX2_linuxY6
3.备份/etc目录中所有名字带有数字并且以.conf结尾的文件到桌面上的confdir中
这部分因为一些原因电脑不能运行,有错误的话请多指教。
# cp /etc*[[:digit:]]*.conf confdir/
5.删掉刚才建立或者备份的所有文件
rm -f ##强制删除文件
rm -fr ##强制删除目录
# rm -fr CLASS*
# rm -fr SINGLE
# rm -fr confdir
# rm -fr DOUBLE
# rm -fr study
页:
[1]