Truncating files in directory
I truncated the files in one of the directory with .log extension.
I wrote a script something like this:
filecount=`ls -1 *.log 2>/dev/null | wc -l`
if [ $filecount -gt 0 ]
then
for i in `ls -1 *.log`
do
echo > $i
done
fi
Here, when it all the files perfectly except the last file. For the last file, instead of truncating it , it creates a new files with same name appended with ? at the end of the file name.
How can overcome this problem. is there something wrong with my script.
|