In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "Linux file query and search command detailed explanation", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's train of thought slowly in depth, together to study and learn "Linux file query and search command detailed explanation"!
1. Command find
The find command is used to find files in the directory structure in the following format:
Find [path] [parameter] [keyword]
The path is the directory path to be found. If it is not written, it means to search under the current directory. The keyword is part of the file name. The main parameters are as follows:
-name searches by file name to find files that match filename. Wildcards can be used.
-depth starts with the deepest subdirectory under the specified directory.
-gid looks for files or directories that match the specified group identification number.
-group looks for files or directories that match the specified group name.
-size looks for files that match the specified file size.
-type looks for files that match the specified file type.
-user looks for files or directories that match the specified owner name.
There are many parameters of the find command, which are commonly used. For other parameters, you can find them on the Internet. Let's take a look at how to use the find command to search for files. Let's search for files starting with "vim" in the directory / etc as an example, as shown in the figure:
Find command operation
As you can see from the figure, files starting with "vim*" in the directory / etc are not listed one by one, such as / etc/vim, / etc/vim/vimrc, and so on.
2. Command grep
The find command is used to search for files in the directory. Sometimes we need to search for a string of keywords in the file. Grep completes this function. The grep command is used to find the file containing the specified keyword. If the content of a file contains the specified keyword, the grep command marks the line containing the specified keyword. The format of the grep command is as follows:
Grep [parameters] keyword file list
The grep command can only look up one keyword at a time. The main parameters are as follows:
-b mark the bit number of the 1st character of the column before displaying the column that matches the keyword.
-c calculates the number of columns that match the keyword.
-d you must use this parameter when you specify that you are looking for a directory instead of a file! Otherwise, the grep instruction will return the information and stop the search.
-I ignores character case.
-v reverses the lookup, showing only rows that do not match.
-r looks for it recursively in the specified directory.
For example, we recursively look for the file containing the character "Ubuntu" under the directory / usr, as shown in the figure:
Command grep demonstration
3. File type query command
Use the command "ls-l" under the user root directory to view the details of all files under the user root directory, as shown in the figure:
File details
In the figure, the details of each file are on one line, and each line is preceded by a symbol that marks the current file type. For example, the first character of test1 is "d" and the first character of test1.tar.bz2 file is "-". The file types represented by these characters are as follows:
-ordinary files, created by some applications, such as documents, pictures, music, etc.
D directory file.
C character device file, Linux driver inside the character device driver, such as serial device, audio device and so on.
B block device files, storage device drivers, such as hard drives, USB drives, etc.
L symbolic connection file, which is equivalent to a shortcut under Windwos.
S socket file.
P pipe file, mainly refers to FIFO file.
Thank you for your reading, the above is the content of "detailed explanation of Linux document query and search command". After the study of this article, I believe you have a deeper understanding of the problem of detailed explanation of Linux file query and search command, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.