exec.sh 436 B

123456789101112131415161718
  1. #!/bin/bash
  2. # Check if the file path is provided
  3. if [ -z "$1" ]; then
  4. echo "Usage: $0 <file path>"
  5. exit 1
  6. fi
  7. # File path from the first argument
  8. input_file="$1"
  9. # Define the output file name
  10. output_file="${input_file%.*}_no_newlines${input_file##*.}"
  11. # Remove newline characters and save to a new file
  12. tr -d '\n' < "$input_file" > "$output_file"
  13. echo "\n" >> "$output_file"
  14. echo "Newlines removed. Output file is: $output_file"