周六实践作业

1) 应用vi命令在/tmp文件夹下创建文件,文件名newfile。在newfile首行输入日期时间

[root@localhost ~]# vi tmp/newfile
 
2023.03.12  10.45
(2) 将/boot/grub2/grub.cfg文档的内容读入到newfile文档中(在日期的下一行即第2行)
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
 
### BEGIN /etc/grub.d/00_header ###
set pager=1
 
if [ -f ${config_directory}/grubenv ]; then
  load_env -f ${config_directory}/grubenv
elif [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi
 
if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi
 
export menuentry_id_option
 
if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi
 
function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}
 
function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
(3) 查找文档中包含#号字符的行,将整行删除

(4) 开启VI的行号提示功能

:set nu   

文件查看:查看newfile文件的第6行

[root@localhost ~]# head -6 /tmp/newfile | tail -1
  load_env -f ${config_directory}/grubenv
查找文件 /usr/share/xml/xml.xsd 中包含字符串 re 的所有行。将所有这些行的副本按原始顺序放在文件/root/files 中

[root@localhost ~]# grep [re] /usr/share/xml/xml.xsd
[root@localhost ~]# grep [re] /usr/share/xml/xml.xsd |cp -r /root/files
cp: missing destination file operand after '/root/files'
Try 'cp --help' for more information.
[root@localhost ~]# 
[root@localhost ~]# grep [re] /usr/share/xml/xml.xsd |cp -a /usr/share/xml/xml.xsd /root/files
[root@localhost ~]# stat /root/files
  File: /root/files
  Size: 8838          Blocks: 24         IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 17877238    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:usr_t:s0
Access: 2023-03-12 13:38:04.158107190 +0800
Modify: 2018-05-04 14:10:16.000000000 +0800
Change: 2023-03-12 13:48:17.820922422 +0800
 Birth: 2023-03-12 13:48:17.820922422 +0800
[root@localhost ~]# stat /usr/share/xml/xml.xsd
  File: /usr/share/xml/xml.xsd
  Size: 8838          Blocks: 24         IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 318562      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:usr_t:s0
Access: 2023-03-12 13:38:04.158107190 +0800
Modify: 2018-05-04 14:10:16.000000000 +0800
Change: 2023-03-10 13:19:55.826707670 +0800
 Birth: 2023-03-10 13:19:55.826707670 +0800

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值