The UNIX and Linux Forums  


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



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
cannot get logic for concatenation awk user_prady Shell Programming and Scripting 7 12-10-2007 03:09 AM
Concatenation Asteroid Shell Programming and Scripting 11 04-04-2007 07:15 AM
File Concatenation samit_9999 UNIX for Dummies Questions & Answers 3 11-21-2006 06:26 AM
string concatenation systemsb UNIX for Dummies Questions & Answers 7 04-04-2006 01:03 PM
Concatenation videsh77 Shell Programming and Scripting 2 12-14-2004 06:13 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-18-2005
jvander jvander is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 20
File concatenation problem

I have written a script to find particular text files created within the last 24 hours and concatenate them all into a single concat.txt file. The problem that I am running into is that the last line of the text files do not terminate with <CR><LF> characters (as do all the other lines in each file). The lack of line termination characters at the end of the last lines causes the files to 'wrap' together: line1 of file2 is appended to the end of the last line of file1, and line 1 of file3 is appended to the end of file 2, etc. (This file format has given me alot grief overall with other things, since for instance tail doesn't work right if line don't have \n at the end, etc.)

Anyway, to resolve this, I wrote the code below to append a <newline> character to the end of each file as files are concatenated. This works except that it results in a single blank line between each file, that I have to remove using sed. I don't understand why I'm getting blank lines since without the added \n, the lines wrapped together.

Here's my code:

find ${ARCH_DIR} -name 'AA20*txt' -ctime -${DAYSCNT} -exec cat {} \; -exec echo "\n" \; >> ${CATFILENAME}

sed '/^$/d' $CATFILENAME > $TEMPFILE

Is there an easier and better way to concatenate text files that have no line termination characters at the end of the last line, especially one that doesn't add blank lines?

Any help would be much appreciated.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0