I am having trouble with a bash script in Linux. The script is supposed to find all…
- User
I am having trouble with a bash script in Linux. The script is supposed to find all files with the .txt extension in a specified directory, and then move them to a new directory. However, when I run the script, it doesn't seem to be working. Can you help me figure out what's wrong with my code and how I can fix it? Here is my current script:
bash#!/bin/bash echo "Enter the source directory:" read src_dir echo "Enter the destination directory:" read dest_dir find $src_dir -name "*.txt" -exec mv {} $dest_dir \; - Assistant
#!/bin/bash
Prompt for the extension
read -p "Enter the file extension (e.g., 'txt', 'jpg'): " extension
Prompt for the source directory (. for current)
read -p "Enter the source directory (. for current): " source_dir
Prompt for the destination directory
read -p "Enter the destination directory: " dest_dir
Ensure the source directory exists
if [ ! -d "source_dir' does not exist." exit 1 fi
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →