Using grep to search for code and convenience is the most primitive and commonly used:
? ~ grep ‘NuPlayer‘ -iInr --color ./aosp
'I' indicates case-insensitive, 'I' indicates that binary files are ignored, 'n' indicates the row number of the search result, and 'R' indicates recursive search subdirectories.
However, grep search is a little slow, and there are many ways to speed up the search by creating indexes on the Internet: "Other grep-like tools and indexing Tools"
Mac, which has always been known for user experience, is not missing. 'spotlight 'is an index-based search tool provided by the system. It is easy to use and CTRL + space calls out. If you want to adjust the directory where the search result file is located, press and hold the command key to enter.
'Spotlight 'certainly has a more custom command line version: 'mdfind '. The search command above can be used for this purpose:
? ~ mdfind ‘NuPlayer‘ -onlyin ./aosp | xargs grep ‘NuPlayer‘ -iInr --onlyin ./aosp
The search speed is dozens of times faster than that in Android code. Here, '-onlyin' tells the command to be searched only in this directory, or else it will be searched on the entire hard disk (but it will be very fast). You may wish to make a function in 'bash _ profile:
function fastfind {mdfind [email protected] -onlyin . | xargs grep [email protected] -riIn .;}
Due to index restrictions, the 'mdfind 'search object does not support regular expressions, but these should be enough:
Mdfind ''str1 str2 "indicates that str1 and str2 appear simultaneously
Mdfind "str1 | str2" indicates that
Mdfind "str1-str2 indicates str1 appears but str2 does not appear
For more advanced usage of 'mdfind ', refer to the metadata definition of spotlight and spotlight.
The metadata defined by spotlight is not very easy to understand. However, you can find out the following when you press the 'mdls' command:
? ~T mdls ~/Movies/Practise.mp4kMDItemAudioBitRate = 48kMDItemAudioChannelCount = 2kMDItemCodecs = ( "H.264", AAC)kMDItemContentCreationDate = 2012-01-05 21:59:18 +0000kMDItemContentModificationDate = 2012-01-05 21:59:18 +0000kMDItemContentType = "public.mpeg-4"kMDItemContentTypeTree = ( "public.mpeg-4", "public.movie", "public.audiovisual-content", "public.data", "public.item", "public.content").....kMDItemFSName = "Practise.mp4"......? ~T mdfind ‘kMDItemCodecs=H.264‘ | grep ‘Practise‘/Users/hong/Movies/Practise.mp4
In spotlight, metadata starting with 'mditem' is used for indexing.
Command Line Control can look at this again: "Use spotlight with command line"