一.
1.应用vi命令在/tmp文件夹下创建文件,文件名newfile。在newfile首行输入日期时间
[xiaopan@localhost ~]$ su
Password:
[root@localhost xiaopan]# cd /tmp
[root@localhost tmp]# vi newfile
回车键进入newfile,按i对文件进行编辑,然后在第一行输入时间日期
2.将/boot/grub2/grub.cfg文档的内容读入到newfile文档中(在日期的下一行即第2行)
在输入日期后按esc退出编辑模式,输入:进入末行模式
:r /boot/grub2/grub.cfg
3.查找文档中包含#号字符的行,将整行删除
同样esc退出,输入:
:g/#/d
4.开启VI的行号提示功能
esc退出,输入:
:set nu
二.
文件查看:查看newfile文件的第6行
[root@localhost tmp]# head -6 newfile|tail -1 newfile
三.
查找文件 /usr/share/xml/xml.xsd 中包含字符串 re 的所有行。将所有这些行的副本按原始顺序放在文件/root/files 中
[root@localhost /]# ls user
ls: cannot access 'user': No such file or directory
[root@localhost /]# cat user
cat: user: No such file or directory
[root@localhost /]# cat /user
cat: /user: No such file or directory
[root@localhost /]# ls /user
ls: cannot access '/user': No such file or directory
[root@localhost /]# cd /user
bash: cd: /user: No such file or directory
问题:这个user不知道为什么进不去
该文介绍了如何使用vi编辑器在Linux系统中创建新文件并添加内容,包括将已有文件内容追加到新文件、删除特定行以及开启行号显示。同时,展示了使用head和tail命令查看文件特定行,以及使用grep命令查找包含特定字符串的行并复制到新文件的操作。然而,在尝试访问/user目录时遇到了不存在的文件或目录的错误。
581

被折叠的 条评论
为什么被折叠?



