The drive_search.sh script allows users to search for or extract specific key information types (e.g., phone numbers, URLs, email addresses, IPs, usernames) from files within a directory.
./drive_search.sh <operation_type> <key_information_type>
-
operation_type:0for searching files that may contain the specified key information.1for extracting the specified key information from all files.
-
key_information_type: Specify the type of key information to search for. Valid options are:phoneurlemailipusername
- The script first checks for the correct number of arguments.
- It defines regex patterns for different types of key information.
- The script ensures that there are searchable files in the directory.
- Depending on the
operation_type:- The script either searches files for the specified pattern.
- Or extracts and displays the specified pattern from the contents of the files.
Command:
./drive_search.sh 0 phoneOutput: (Include a screenshot of the output here)
Command:
./drive_search.sh 1 emailOutput: (Include a screenshot of the output here)
If you encounter the following error:
./drive_search.sh: line 23: syntax error near unexpected token `$'in\r''
'/drive_search.sh: line 23: `case $operation in
This suggests that the script has Windows-style line endings. To fix this, you can use the dos2unix tool:
dos2unix ./drive_search.shEnsure that you have the necessary permissions to execute the script. If not, you can make the script executable using the command:
chmod +x drive_search.sh