Searching!!
There are many ways to search for content. Below are some of the effective ways to search for the content or file.
Using Grep
grep -ri -C 2 -E 'password|user' <Folder or files name>
# grep -Ei "credential|user|password|username|secure" *.ps1
# Example in which line number of matching value is displayed.
cat shell.php | grep -ni "changed this"# Example:
# grep -ri -C 2 -E 'password|user' joomla/Explanation of Options:
-r: Recursive search through directories.-i: Case-insensitive search.-C 2: Show 2 lines of context before and after matches.-E: Enables extended regular expressions.-n: Displays the line numbers of the matching lines.
Using Select-String & where-object
Select-String
"Task To Run.exe.": This regular expression matches lines containing "Task To Run" followed by any characters (.*), and then "exe".
We can use "-Context 0,1" to make the search easy.
"-Context 0,1:" Shows 0 lines before and 1 line after each match.
Where-Object
Common Operators
-match: Matches a value using a regular expression (case-insensitive by default).Example:
$_.Name -match "pattern"
-notmatch: Excludes values that match a regular expression.Example:
$_.Name -notmatch "pattern"
-like: Matches a value using wildcards (*for multiple characters,?for a single character).Example:
$_.Name -like "*value*"
-notlike: Excludes values that match a wildcard pattern.Example:
$_.Name -notlike "*value*"
-eq: Checks if a value is equal (case-insensitive for strings).Example:
$_.Status -eq "Active"
-ne: Checks if a value is not equal.Example:
$_.Status -ne "Inactive"
Example from the command above:
$_ -notmatch "system32"checks if the current line/object does not containsystem32.$_ -notmatch "Next Run Time:\s+N/A"checks if the current line/object does not matchNext Run Time: N/A.
Find Command
Showing all content in a folder.
Searching for file
In Windows:
If you want to get data from the file then you can use the below command:
CMD search Functionality:

In linux:
Flag Finding
In Windows:
In Linux:
One liner:
Last updated