Command Line Search

How to guides and answers to Frequently Asked Questions

Moderator: vuser

Locked
FileViewer
Site Admin
Posts: 287
Joined: Fri Apr 30, 2010 5:50 pm

Command Line Search

Post by FileViewer »

You can now initiate a V search (GREP) from the command line. Note that the search results are displayed in V - not on the command line. If you want the results displayed on the command line, I suggest you either use Windows' FINDSTR command and/or GNU Grep: http://www.gnu.org/software/grep/

All command line options are case insensitive. That is, they can either be in upper or lower case.

Searching for files (/sf option)

Code: Select all

V /sf [/s][/zip][/ads][/es] [/d:]Directory [/m:]FileMask

/s     Search Subdirectories
/zip   Search Inside Archives
/ads   Include Alternate Data Streams
/es    Use Everything Search
Note that /d: and /m: are optional, as V can usually determine which parameter is the directory and which is the file mask. If you do not enter a directory, V will search the directory from which the command was executed.

If Everything Search (ES) is installed, you can use /es to let ES perform the search. In this case, it is not necessary to use the /sf option. Note that if you do not specify a directory when using /es, V will search all drives that ES is monitoring and not just the current directory.

Examples:

Code: Select all

V /sf /s *.cpp         ; Recursively search for *.cpp in the current directory
V /sf C:\src *.cpp     ; Search for .cpp files in C:\src
V /es *.tmp            ; Search for all .tmp files (across all drives ES is monitoring)
V /es /S *.tmp         ; Recursively search for all .tmp files in the current directory
To search for text in files (GREP), you would use the /st option as follows:

Code: Select all

V /st [/s][/zip][/ads][/es][/ib][/bin][/re][/mc][/sc:col][/so:opt] [/s:]string [/d:]Directory [/m:]FileMask

/s        Search subdirectories
/zip      Search Inside Archives
/ads      Search Alternate Data Streams
/es       Use Everything Search to locate the files
/bin      The search string is in binary (hex)
/ib       Ignore Binary Files
/re       The search string is a regular expression
/mc       Match case option
Note that /s:, /d: and /m: are optional as V can usually determine which parameter is the string and which is the directory or file mask. If you do not enter a directory, V will search the directory from which the command was executed.

Examples:

Code: Select all

V /st /s FunctionName() *.cpp            ; Recursively search all the .cpp files in the current directory for FunctionName()
V /st /s FunctionName() C:\src *.cpp     ; Recursively search all the .cpp files in C:\src for FunctionName()
V /st /es FunctionName() *.cpp           ; Use ES to locate *all* .cpp files and search them for FunctionName()
The /so option is used to specify one or more search string options when searching for text:

Code: Select all

/so:[CWRHU]

C        Match case (can also use /mc)
W        Word Only
R        Regular Expression (can also use /re)
H        Hex/Binary (can also use /bin)
U        Unicode
The /sc: option is used to specify a column range when searching for text

Code: Select all

/sc:n      Match the string if it begins in column n
/sc:n-m    Match strings that start anywhere between columns n and m (eg /sc:25-30)
/sc:n-     Match strings that start anywhere after (and including) column n 

You can also specify multiple column range by separating them with commas. For example, /sc:8-12,40,80
Locked