Regular Expressions and grep exercises (Linux)

Source: Internet
Author: User

1, in the current system create user student Student1 Student2, find the current system named student (must appear at the beginning) of the user's account and related information, the file is/etc/passwd

grep "^student\>"/etc/passwd | Cut-d:-F3

2, analyze the following text in the/etc/inittab file the characteristics of the first two lines (where the number must be the same in each line), write a pattern that can be found exactly like two lines:

11:1:WAIT:ETC/RC.D/RC 1

13:3:WAIT:ETC/RC.D/RC 3


grep "^1\ ([0-9]\): \1.*\1$"/etc/inittab

3, displays all files that end with a number and do not contain white space in the file name

LS *[^[:space:]]*[0-9] File name


4. Find the number between 1-255 in the/boot/grub/grub.conf file

\< ([1-9]|[ 1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]) \>

Regular Expressions and grep exercises (Linux)

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.