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

10.Write a shell script to count the number words,lines,character from given file accept file name from commandline.

2.Write a shell script to compile all C files and delete those files having errors.