This bash script provides an interactive menu for selecting files from a specified directory and executing a command on the selected file. The results of the command are then saved in another specified directory.
- Ensure you have the necessary permissions to execute the script (
chmod +x ips.sh
). - Customize the script by specifying the source directory where your files are located and the destination directory where you want to save the results.
- Run the script (
./ips.sh
) and follow the on-screen instructions.
- Interactive menu for file selection.
- Executes a specified command on the selected file.
- Saves the results of the command in a separate file.
- This script relies on standard bash commands and does not require any additional dependencies.
Suppose you have a directory /path/to/files
containing text files. You want to extract IP addresses from each file using the httpx
command and save the results in /path/to/results
.
- Customize the script by setting
source_directory="/path/to/files"
anddestination_directory="/path/to/results"
. - Run the script (
./file_processor.sh
). - Select the file you want to process from the menu.
- The script will execute the command
cat "$selected_file" | httpx -ip -silent | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'
on the selected file and save the results in"$destination_directory/$selected_file.txt"
.
This script is licensed under the MIT License.