RCHE7 management II-2 using regular expressions with grep

Source: Internet
Author: User

Grep

-I: Ignore case

-N: Indicates the number of rows

Find the row that contains the root

# grep root/etc/passwdroot:x:0:0: root:/root:/bin/bashoperator: x: One:0:operator:/root:/sbin/nologin

Find the line with root, need to add special characters "^"

# grep ^root/etc/passwdroot:x:0:0: Root:/root:/bin/bash

Find the line ending with "/sbin/nologin" and need to add special characters "$"

# grep/sbin/nologin$/etc/passwdbin:x:1:1: bin:/bin:/sbin/nologindaemon:x: 2:2:d aemon:/sbin:/sbin/nologinadm:x:3:4: adm:/var/adm:/ Sbin/nologin

Find the line that does not appear root

# grep-v root/etc/passwdvboxadd:x:992:1::/var/run/vboxadd:/bin/False  dhcpd:x:177:177:D HCP Server:/:/sbin/nologin

Find rows that have neither root nor nologin

# grep-v Root/etc/passwd|grep-v nologinsync:x:5:0: sync:/sbin:/bin/syncshutdown:x:6:0: shutdown:/sbin:/sbin/shutdownhalt:x:7:0: halt:/sbin:/sbin/haltyb:x: +: +: yb:/home/yb:/bin/bashvboxadd:x:992:1::/var/run/vboxadd:/bin/false# grep-e-v root\|nologin/etc/passwdsync:x:5:0: sync:/sbin:/bin/syncshutdown:x:6:0: shutdown:/sbin:/sbin/shutdownhalt:x:7:0: halt:/sbin:/sbin/haltyb:x: +: +: yb:/home/yb:/bin/bashvboxadd:x:992:1::/var/run/vboxadd:/bin/false

Examples of grep and RPM use together

Find the file network-scripts belongs to which installation package # RPM-qf/etc/sysconfig/network-scripts/initscripts-9.49. --1. el7.x86_64 Find Initscripts-9.49. --1where is the help document for the. el7.x86_64 package [[email protected] initscripts-9.49. -]# RPM-QD initscripts-9.49. --1. el7.x86_64/usr/share/doc/initscripts-9.49. -/COPYING/usr/share/doc/initscripts-9.49. -/Changes.ipv6/usr/share/doc/initscripts-9.49. -/ipv6-6to4.howto/usr/share/doc/initscripts-9.49. -/ipv6-Tunnel.howto/usr/share/doc/initscripts-9.49. -/Static-routes-IPv6/usr/share/doc/initscripts-9.49. -/Sysconfig.txt/usr/share/doc/initscripts-9.49. -/Sysvinitfiles/usr/share/man/man1/consoletype.1. GZ/usr/share/man/man1/genhostid.1. GZ/usr/share/man/man1/ipcalc.1. GZ/usr/share/man/man1/netreport.1. GZ/usr/share/man/man1/usleep.1. GZ/usr/share/man/man8/ifdown.8. GZ/usr/share/man/man8/ifup.8. GZ/usr/share/man/man8/ppp-watch.8. GZ/usr/share/man/man8/service.8. GZ/usr/share/man/man8/sushell.8. GZ/usr/share/man/man8/sys-unconfig.8. GZ/usr/share/man/man8/usernetctl.8. GZ Enter the directory where the Help document is located, view the Configure IP Document # CD/usr/share/doc/initscripts-9.49. -# grep-ri'ipaddr'*--Here's *represents all files, R is recursive, I means ignore case IPv6-6to4.howto:ipaddr=XX.YY.ZZ.WW [Globally unique IPv4 Address]ipv6-6to4.howto:address (ipaddr= above), here'193.94.160.1'. Sysconfig.txt:bother to define; outWhat"ipaddr"  is, Isysconfig.txt:IPADDRn=Sysconfig.txt:LOCAL_IP='ll be converted to ipaddr by Netconfsysconfig.txt:MY_INNER_IPADDR=local IP address of the tunnelInterfaceSysconfig.txt:PEER_OUTER_IPADDR=IP address of the remote tunnel Endpointsysconfig.txt:MY_OUTER_IPADDR=IP address of the local tunnel Endpointsysconfig.txt:PEER_INNER_IPADDR=IP address of the remote end of the tunnelInterfacesysconfig.txt:If This  isspecified, a route to peer_inner_ipaddr through the tunnel# more Sysconfig.txt

RCHE7 management II-2 using regular expressions with grep

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.