将文本中每一行中的空格删除
#!/bin/bash
# Check if a file name is passed as an argument
if [ $# -eq 0 ]; then
echo "Please provide the filename as an argument."
exit 1
fi
# Read the passed filename
filename="$1"
# Check if the file exists
if [ ! -f "$filename" ]; then
echo "File '$filename' does not exist."
exit 1
fi
# Use sed command to delete spaces from each line and overwrite the original file
sed -i 's/ //g' "$filename"
echo "Spaces have been removed from the file '$filename'."