0% found this document useful (0 votes)
5 views2 pages

Shell Script to Remove Spaces from File

The document provides a shell script to delete all spaces from a specified file. It checks if the file exists and uses the 'tr' command to remove spaces, outputting the result to a new file. Multiple variations of the script are also presented for user input and file handling.

Uploaded by

for11trade
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Shell Script to Remove Spaces from File

The document provides a shell script to delete all spaces from a specified file. It checks if the file exists and uses the 'tr' command to remove spaces, outputting the result to a new file. Multiple variations of the script are also presented for user input and file handling.

Uploaded by

for11trade
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Script No .

Definition:
Write a shell script to delete all the spaces from a given file.
Script:
clear

echo Enter the name of the file


read fn

if [ -f $fn ]

then

echo File $fn exists


cat $fn | tr -d " " > newfn

cat newfn

else
echo file doe not exists

fi

OR
echo "enter the filename"
read datafile
cat $datafile | tr -d '[:space:]'>newfile

OR
echo "Enter file name"
read fn
cat $fn | tr -d " "
cat [Link]

You might also like