[Small exercise] grep exercise

Source: Internet
Author: User
Exercise:
1. display the lines starting with "S" of the/proc/meminfo file with no size difference;
Grep-I s/proc/meninfo
2. display the rows ending with nologin in/etc/passwd;
Grep nologin $/etc/passwd
3. the/etc/inittab starts with #, followed by one or more blank characters, and followed by any character rows;
Grep -- color ^ #. */etc/inittab
4. the/etc/inittab displays the rows of a number (that is, a number between two colons;
Grep: [0-9]:/etc/inittab
5. display the lines starting with one or more blank characters in the/boot/GRUB/grub. conf file;
Grep ^ [[: Space:] \ {1, \}. * "/boot/GRUB/grub. conf
Grep-e -- color "^ [: Space:] {1,}. *"/boot/GRUB/grub. conf
6. display the rows starting with a number in the/etc/inittab file and ending with the same number as the starting number;
Grep "^ \ ([0-9] \). * \ 1 $"/etc/inittab
7. The ifconfig command can display information related to the IP address of the current host. If you use the grep or other text processing commands to retrieve the IP addresses of the local host, the requirements do not include 127.0.0.1;
Ifcofig | grep "Inet ADDR" | grep-V '2017. 0.0.1 '| cut-D:-F2 | cut-d "" F1
8. The/etc/sysconfig/network-scripts/ifcfg-eth0 file contains a line similar to an IP address point in decimal format;
Grep-e "([0-9] {1, 3} \.) {3} \. [0-9] {1, 3}"/etc/sysconfig/network-scripts/ifcfg-eth0
Grep "[0-9] \ {1, 3 \}\. "\ {3 \}\. [0-9] \ {1, 3 \}/etc/sysconfig/network-scripts/ifcfg-eth0

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.