![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Padding Carriage return to the end of XML file | dasj22 | UNIX for Advanced & Expert Users | 3 | 05-23-2008 09:31 AM |
| Issue with Removing Carriage Return (^M) in delimited file | sirahc | UNIX for Advanced & Expert Users | 7 | 03-25-2008 05:08 AM |
| add carriage return at end of file | HAA | Shell Programming and Scripting | 2 | 11-20-2007 11:58 AM |
| Removing Carriage Return and or line feed from a file | tbone231 | Shell Programming and Scripting | 1 | 02-18-2005 04:37 PM |
| Removing carriage return characters from file | b1saini | UNIX for Dummies Questions & Answers | 3 | 09-10-2003 09:41 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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"`" |
|
||||
|
Quote:
![]() |
|
||||
|
It just has a blank line at the end
--------------- 09/01/06 09/02/06 09/03/06 09/04/06 09/05/06 09/06/06 09/07/06 09/08/06 09/09/06 09/10/06 09/11/06 09/12/06 09/13/06 09/14/06 09/15/06 09/16/06 09/17/06 09/18/06 09/19/06 09/20/06 09/21/06 09/22/06 09/23/06 09/24/06 09/25/06 09/26/06 09/27/06 09/28/06 09/29/06 09/30/06 <---Want to remove this blank line. -------------------------------- Thanks. |
|
||||
|
Above code should work. I dont know whats happening in your case.
Try this Code:
sed "$ d" $outdir/date.txt > temp mv temp $outdir/date.txt |
| Sponsored Links | ||
|
|