Search for file content under Linux is commonly used grep, search file information using find
1, grep
Search text command
Command format: grep [options ]... pattern [file]...Command Format: grep Find Rule... Regular Expression View File 1.1 Find Rule
pattern regex main parameters:
Ignore case search
grep -i "androiD" Logcat.txt //from the logcat.txt file, search for text lines containing android, not case sensitive
traverse search, and no match information is displayed
grep -rs "android" //From the current directory, iterate through all the files and search for the text line containing android
The whole word matches the search grep -w “android” logcat.txt //from the logcat.txt file In, search for the text line containing the word android grep -w “android |
ios & rdquo; logcat.txt //from logcat.txt file, search containing the word android or ios lines of text
list the file names
grep -l " android "
Statistics occurrences
grep -c "android" .
Display the line where the characters appear
grep -n "android“ .
p>(1) If not, the default is the current path; (2) Support multiple paths, the directory is directly separated by spaces;
find . -name demo2.2 Find rules
2.2.1 According to the file name ( Name)
-name //Search by file name, case sensitive -iname //Search by file name, case insensitive
Wildcard Description: (1)* Matches any number Characters (2)? Match any single character (3)[] Match any character in parentheses
find /data -name dalv I*find /data -name dalvik?cachefind /data -name dalvik-cach[abe]2.2.2 Depending on the file type (type)
Example:
find -type f //View file type 2.2.3 Depending on the directory depth
Unit: c (lowercase), k (lowercase), M (uppercase), G (uppercase)
-size +10M: Find files larger than 10M -size -2k: Find files smaller than 2k -empty: Find files with size 0 or empty directories
2.2.5 Based on files Permissions (perm)
Example:
find -perm 777 //Find files with permissions 777 2.2.6 Depending on the user and group to which the file belongs
You can use the stat command to view the time of the file. The following are the files according to each. Time to find files:
For example, look up the current path, start with a, and exclude the end with b Document or Folder:
find -name a* -not -name *b2.3 Execute
-ls Find the result, display it as ls
find -name app -ls
-ok [command] After the search is complete, execute the command and ask for execution
find -name App -ok cat {} \\; //Note: There are spaces before and after {}
-exec [command] After the search is complete, execute the command and execute
find -name app -exec Ls {} \\;
1. /The root partition is a mandatory partition, partitioned according to your actual situation. 2.
Linode VPS default time zone is US, which is inconvenient for performing some scheduled tasks. There
Description of Requirement compile and install MySQL, PHP , and Apache to work a. The process o
Linux shared memory Shared memory is a memory area reserved by the system for communication between
Summary of gcc compilation and proc compilation under linux
Analysis of the lower part of the Linux 2.6 interrupt
Detailed explanation of the meaning of ctime atime mtime for files and folders under Linux
Windows under the wrong formatted Linux SWAP partition recovery
Linux Network Programming - socket option
Linux vmware tools under VMware Workstation VM
Linux shell script to remove source annotations
Linux memory view command free
How to clear the redundant option in the device driver
Win7 Ultimate system using u disk to speed up the system speed
First install win2000/XP, then install DOS/win98
The method of sending the article on WeChat to the computer
How to set the default browser win7?
SVN1.6 server and client installation configuration steps
Lumia Win10 did not release a new mobile phone, where is the way for Microsoft mobile hardware?
Win8 uses the task scheduler to add the task manager as a boot entry