Wednesday, May 2, 2018

linux - basename command is outputting an 'enter' character along with the file name

I'am reading a text file line by line using while loop whose contents are directories and file names. I read the file names using basename command. I want to check if that file exists in a directory. But the below written code does'nt work. When i echo the basename command, it is outputting an 'enter' character along with the file name. How do i remove the 'enter character' ?


while read line;do
file=`basename "$line"`
dir=`dirname "$line"`
if [ -f "/data/config/${file}" ]; then
echo "${file} is present"
fi
done < /data/textfile.txt*

content of textfile.txt is given below


config/local/common/environment.properties
config/local/common/jmsservices.xml
config/local/common/ejbservices.xml

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...