The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 10-20-2006
bd_joy bd_joy is offline
Registered User
  
 

Join Date: Aug 2005
Location: Pittsburgh, PA
Posts: 25
Carriage Return at end of file

Hi, I have a script that outputs a file that contains the dates from the previous month, which is then used by our application to run processes on each date contained in the file. My problem is is that my script created a blank line at the bottom of the file which causes issues for our application. I'm looking for suggestions on how to stop or remove the last line/carriage return. Any suggestions are appreciated. Thanks!


Here is the current script:

echo "Creating DATES file. `date +"%m-%d-%Y_%H:%M:%S"`"
outdir=/test/iofiles

# ja fe ma ap ma ju ju ag se oc no de
set -A lasts 0 31 28 31 30 31 30 31 31 30 31 30 31
typeset -Z2 dmonth dday

month=`date +%m`
year=`date +%y`
((pmonth=month-1))

rm $outdir/date.txt

day=1
while((day<(lasts[pmonth])+1)) ; do
dday=$day
dmonth=$pmonth
echo ${dmonth}/${dday}/${year} >> $outdir/date.txt
((day=day+1))
done
echo "DATES file created. `date +"%m-%d-%Y_%H:%M:%S"`"