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

Popular posts from this blog

3.Write a shell script to print below pattern 1 1 2 1 1 3 3 1