0

In a folder I have multiple text files, suppose:

  • file1.txt
  • file2.txt
  • file3.txt

I use this script, saved in the same folder, to combine the content of that files into one,

if [ -a ALL.txt ]; then
rm ./ALL.txt
fi

for i in *.txt; do 
mv "$i" "`echo $i | sed -e 's, ,-,g'`"; 
done;

for f in *.txt; do
echo '' >> "$f"
done

for i in *.txt; do 

cat $i >> ./ALL.txt

done

but this script adds one new line at the end of each file every time I run it. How to avoid it?

Neuran
  • 137
  • 10

0 Answers0