Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the common command ack in Linux

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about how to use the common command ack in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Linux common commands the ack command is a search tool similar to grep that is optimized for programmers.

Ack is similar to grep's text search tool.

Install ack-grep under # ubuntu, because in the debian system, the name ack is occupied by other software. Sudo apt-get install ack-grep # alpine Linux-apk package Manager installs the ack apk install ack parameter-c (statistics) /-I (ignore size) /-h (do not show name) /-l (show file name only) /-n (plus line number) /-v (show mismatch). The ack official website lists the 5 selling points of this tool:

It's very fast because it only searches for meaningful things.

Do more friendly searches and ignore things that are not your source code.

Designed for source code search, complete tasks with fewer keystrokes.

Very light, good portability.

Free and open source

Examples in memory can be roughly divided into these parts:

Searching code search Search output search results process File presentation files display File finding files find File inclusion/exclusion files filter

Common operations of grep

Grep-r 'hello_world' # simple usage grep'^ hello_world'. # simple regular ls-l | grep .py # pipe usage Searching simple text search, recursive by default.

Ack-grep hello ack-grep-I hello ack-grep-v hello ack-grep-w hello ack-grep-Q 'hello*'Search File processes search results, such as displaying only one match for a file, or xxx

Ack-grep-- line=1 # output all files the second line ack-grep-l 'hello' # contains the file name ack-grep-L' print' # does not contain the file name how does the File presentation output display? there are several parameters in this section that can be practiced.

Ack-grep hello-pager='less-R'# shows ack-grep hello as less-noheading # does not display the file ack-grep hello on the header-nocolor # does not color File finding for matching characters yes, it can find files to save you the hassle of constantly combining find and grep, although in linux's mind it is a tool to do a good job.

Ack-grep-f hello.py # find full matching file ack-grep-g hello.py$ # find regular matching file ack-grep-g hello-- sort-files # find and then sort File Inclusion/Exclusion file filtering, I think this is a very good feature. You will find this useful if you have ever searched for the source code of the project and accidentally hit a keyword in the log.

Ack-grep-python hello # find all python files ack-grep-G hello.py$ hello # find files that match the rules Thank you for reading! This is the end of the article on "how to use ack in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report