RHCSA--Vim 文件查看和查找文件

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

[root@localhost ~]# date > /tmp/newfile
[root@localhost ~]# cat /tmp/newfile
Tue Mar 21 05:50:24 AM EDT 2023

 (2) 将/boot/grub2/grub.cfg文档的内容读入到newfile文档中(在日期的下一行即第2行)

RHCSA--Vim 文件查看和查找文件_第1张图片

(3) 查找文档中包含#号字符的行,将整行删除

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

:g/#/d
:/#  
E486: Pattern not found: # 

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

[root@localhost ~]# head -6 /tmp/newfile |tail -1
Tue Mar 21 05:50:24 AM EDT 2023
[root@localhost ~]# 

3、查找文件 /usr/share/xml/xml.xsd 中包含字符串 re 的所有行。将所有这些行的副本按原始顺序放在文件/root/files 中

[root@localhost ~]# grep re /usr/share/xml/xml.xsd

      See 
      
      Note that local names in this namespace are intended to be
      The names currently defined in this namespace are listed below.
      See further below in this document for more information about how to refer to this schema document from your own
      XSD schema documents and about the
       any element; its value is inherited.  This name is reserved
      Attempting to install the relevant ISO 2- and 3-letter
      going to be a realistic possibility.  
      See BCP 47 at 
      and the IANA language subtag registry at
      
       http://www.iana.org/assignments/language-subtag-registry
     
     
       value is inherited.  This name is reserved by virtue of its
   
    
   
       provides a URI to be used as the base for interpreting any
       relative URIs in the scope of the element on which it
       appears; its value is inherited.  This name is reserved
      href="http://www.w3.org/TR/xmlbase/">http://www.w3.org/TR/xmlbase/
       should be interpreted as if declared to be of type ID.
       This name is reserved by virtue of its definition in the
      href="http://www.w3.org/TR/xml-id/">http://www.w3.org/TR/xml-id/
  
  
  
  
      the original XML Working Group.  This name is reserved by 
	In appreciation for his vision, leadership and
	February, 2000, reserves for Jon Bosak in perpetuity
     
     
     
Subsequently, qualified reference to any of the attributes or the group defined below will have the desired effect, e.g.
           <attributeGroup ref="xml:specialAttrs"/>
     
The schema document at that URI may however change in the future, in order to remain compatible with the latest version of XML document at Previous dated (and unchanging) versions of this schema document are at:
  • [root@localhost ~]# cat /usr/share/xml/xml.xsd |grep re
  • 你可能感兴趣的:(vim,linux,编辑器)