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