In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-10-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article uses easy-to-understand examples to introduce the use of grep commands in linux, the code is very detailed, interested friends can refer to, hope to be helpful.
Grep
Grep is a powerful text search tool that uses regular expressions to search for text and print matching lines.
Common syntax:
[root@www ~] # grep [- acinv] [--color=auto] 'search string' filename
Options and parameters:
-a: search binary files for data in the form of text files
-c: calculates the number of times a 'search string' is found
-I: ignore the case difference, so the case is considered the same
-n: output line number
-v: reverse selection, that is, the line that shows no 'search string' content
-- color=auto: you can color the keywords you find.
For example:
Take out the line where root appears in / etc/passwd
# grep root / etc/passwdroot:x:0:0:root:/root:/bin/bashoperator:x:11:0:operator:/root:/sbin/nologin or # cat / etc/passwd | grep root root:x:0:0:root:/root:/bin/bashoperator:x:11:0:operator:/root:/sbin/nologin
Take out the lines where root appears in / etc/passwd and display the line numbers of these lines in / etc/passwd
# grep-n root / etc/passwd1:root:x:0:0:root:/root:/bin/bash30:operator:x:11:0:operator:/root:/sbin/nologin this is the end of the usage of the grep command in linux. I hope the above content can be of some help and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.