Write a script that deletes all leading and trailing spaces in all lines in a file. Also remove blank lines from a file. Locate lines containing only printf but not fprintf.

echo “Remove all leading and trailing space along with blank lines from a gievn file”

echo -e “Enter the file name::\c”

read fname

if [ -f $fname ]

then

sed ‘s/^[\t]*//;s/[\t]*$//;’ $fname>temp

sed ‘/^$/d’ temp

mv temp $fname

else

echo “file is not present”

fi

 

OUTPUT::

 

Remove all leading and trailing space along with blank lines from a gievn file

Enter the file name::s.txt

hi      hello

echo    hi

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.