When doing Linux command operations, sometimes many directories are searched for, and these directories are not what we need, so we can ignore them. The following small series teaches you how to use the find command to ignore subdirectories.
use the find command on linux find files when the system is sometimes necessary to ignore certain directories, may be used to filter parameters -prune.
However, it must be noted that the path parameter to be ignored must follow the search path, otherwise the parameter will not work.
For example: Specify all files in the /home/zth directory, but ignore the path to /home/zth/astetc:
The code is as follows:
find /home /zth -path “/home/zth/astetc” -prune -o -type f -print
Search by file name:
The code is as follows:
find /home/zth -path “/home/zth/astetc” -prune -o -type f -name “cdr_*.conf” -print
How to ignore more than two paths ?
The code is as follows:
find /home/zth /( -path “/home/zth/astetc” -o -path “/home/zth/etc” /) -prune -o -type f -print
find /home/zth /( -path “/home/zth/astetc” -o -path “/home/zth/etc” /) -prune -o -type f -name “cdr_*.conf” -print
Note: There are spaces before and after /( and /).
Finding a file containing content, the following statement can solve the problem of the directory with spaces:
The code is as follows:
find. /-name “mysql*” -print0 |
Xargs -0 grep “SELECT lead_id FROM vicidial_list where vendor_lead_code”
If the directory does not have spaces, you can do this:
The code is as follows:
find . /-name “mysql*” |
Xargs grep “ SELECT lead_id FROM vicidial_list where vendor_lead_code”
The above is the way to ignore subdirectories when using the find command to find files in Linux. If you need to use related operations, but also use the find command. If you are not very familiar with it, you may wish to learn more about this article and hope to help you.
gmtime and localtime are two different functions. Many people are confused when usi
In the Ubuntu system operation, after compiling Nox and installing make error, what
Linux system operation, sometimes need to modify the environment variable PATH path
There are many commands in Linux system. Some commands are simple and practical, while others are ex
Two styles of chmod command format under Linux/Ubuntu
Linux system smbclient command usage
How to change the resolution of Red Flag Linux6.0sp1 system
Linux function library creation method
Linux system Java is not compatible with Siyuan blackbody solution
Linux scp command usage example summary
How to change the Linux default startup level
How does the Linux shell call another script file
Linux system to delete the specified time period file method
Win7 system with Firefox browser to see flash will appear suspended or stop responding how to do
How to turn off the Windows 8 system cloud synchronization setting function
Windows server 2003 15 practical operation skills
What if Win7 Excel 2007 cannot open Excel 2003 files?
The Arabic numerals in word are converted into uppercase Chinese characters
Restore Win7 Quick Launch Bar Library to My Computer
Win7 system update prompt "80246007" error how to do
Windows 2008 Top Ten Practical Improvements (1)
Microsoft pushes Win10 preview again, the login interface changes greatly