The grep of the Linux command

Source: Internet
Author: User

1: Display the line with the root character in the/etc/passwd

1 grep ' Root ' /etc/passwd21: root:x:0:0: root:/root:/bin/Bash  3: operator:x: One:0: Operator:/root:/sbin/nologin

2: The specified file (test1) reads Hello regardless of the case of the line

1 grep -in'hello'21: Hello3  3: HELLO

Description: The ' hello ' case in grep is ignored

3: Use of Locators ^

Only the first root row appears in the/etc/passwd

1[Email protected] zkero]#grep-N'Root'/etc/passwd2 1: root:x:0:0: root:/root:/bin/Bash3  One: operator:x: One:0: operator:/root:/sbin/Nologin4[Email protected] zkero]#grep-N'^root'/etc/passwd5 1: root:x:0:0: Root:/root:/bin/bash

^ within [] is the inverse selection, outside [] is the locator

4: Display line end word represented descriptor row

1 grep ' bash$ ' /etc/passwd21: root:x:0:0: root:/root:/bin/Bash  3: zkero:x: $: Zkero:/home/zkero:/bin/bash

5: Position display blank line

1[Email protected] zkero]#Cat-N test12      1Hello3      2 World4      3HELLO5      4    6      5 World7      6    8      7I an Supker9      8I like computer!Ten      9     One[Email protected] zkero]#grep-N'^$'test1 A 4: - 6: - 9:

6: General script files have blank lines and lines at the beginning of the # comment, and omit these lines if special needs are required:

 1 [[email protected] zkero]# cat /etc/ sysctl.conf 2# Kernel SYSCTL Configurationfile  forRed Hat Linux3 #4# for binary values,0is disabled,1is enabled. See Sysctl (8) and5# sysctl.conf (5) for  Moredetails.6 7 # Controls IP packet forwarding8Net.ipv4.ip_forward =09 Ten # Controls Source Route verification OneNet.ipv4.conf.default.rp_filter =1 A  - # do not accept source routing -Net.ipv4.conf.default.accept_source_route =0 the  - # Controls The System Request debugging functionality of the kernel -KERNEL.SYSRQ =0 -  + # Controls Whether core dumps would append the PID to the core filename. -# useful forDebugging multi-threaded applications. +Kernel.core_uses_pid =1 A  at # Controls the use of TCP syncookies -Net.ipv4.tcp_syncookies =1 -  - # Disable NetFilter on bridges. -Net.bridge.bridge-nf-call-ip6tables =0 -Net.bridge.bridge-nf-call-iptables =0 inNet.bridge.bridge-nf-call-arptables =0 -  to # Controls The default maxmimum size of a mesage queue +KERNEL.MSGMNB =65536 -  the# Controls The maximum size of a message,inchbytes *Kernel.msgmax =65536 $ Panax Notoginseng# Controls The maximum shared segment size,inchbytes -Kernel.shmmax =68719476736 the  +# Controls The maximum number of shared memory segments,inchpages AKernel.shmall =4294967296 the[Email protected] zkero]#grep-V'^$'/etc/SYSC +sysconfig/sysctl.conf -[email protected] zkero]# grep-V'^$'/etc/sysctl.conf |grep-V'^#' $Net.ipv4.ip_forward =0 $Net.ipv4.conf.default.rp_filter =1 -Net.ipv4.conf.default.accept_source_route =0 -KERNEL.SYSRQ =0 theKernel.core_uses_pid =1 -Net.ipv4.tcp_syncookies =1WuyiNet.bridge.bridge-nf-call-ip6tables =0 theNet.bridge.bridge-nf-call-iptables =0 -Net.bridge.bridge-nf-call-arptables =0 WuKERNEL.MSGMNB =65536 -Kernel.msgmax =65536 AboutKernel.shmmax =68719476736 $Kernel.shmall =4294967296

The grep of the Linux command

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.