18.Write a shell script to delete all empty lines from any file
#!/bin/bash
# Check if a file name was provided
if [ -z "$1" ]; then
echo "Usage: $0 filename"
exit 1
fi
# Remove empty lines from the specified file
sed -i '/^$/d' "$1"
echo "Empty lines removed from $1."
Comments
Post a Comment