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



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
How to combine text data into one line? rcky_mntere Shell Programming and Scripting 2 05-02-2008 01:48 PM
Combine output on same line theninja Shell Programming and Scripting 3 01-14-2008 04:21 AM
append a line to the last line in a file subhrap.das UNIX Desktop for Dummies Questions & Answers 5 04-25-2007 09:17 AM
Using SED to append character to each line c0nn0r Shell Programming and Scripting 4 07-08-2006 09:07 PM
append line ymeyaw UNIX for Dummies Questions & Answers 7 04-09-2006 10:14 PM

Closed Thread
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
  #1 (permalink)  
Old 11-07-2006
ldevito1 ldevito1 is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 2
Combine reports and append a line between each

I am new to Unix and have tried to write a ksh script to do the following without success:

I have several reports in a directory (report1, report2, report3, etc). I would like to combine all of these reports into one file (REPORTS). I would like to append *** End of Report *** to each report so I can easily distinguish between each report in the file.

The output to the REPORTS file should look like:

report1
*** End of Report ***
report2
*** End of Report ***
report3
*** End of Report ***

Any help with this is greatly appreciated.
  #2 (permalink)  
Old 11-07-2006
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Pretty simple....

Code:
$ cat > report1
This is report1
^D
$ cat > report2
This is report2
^D
$ cat > report3
This is report3
^D
$ for file in report*; do
>   cat $file >> REPORTS
>   echo "*** End Of Report ***" >> REPORTS
> done
$ cat REPORTS
This is report1
*** End Of Report ***
This is report2
*** End Of Report ***
This is report3
*** End Of Report ***
Cheers
ZB
  #3 (permalink)  
Old 11-08-2006
ldevito1 ldevito1 is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 2
Thanks for the reply. I tried your suggestion ZB and I get the reports and then all of the ***End of Report*** messages at the end of the file:

report1
report2
report3
***End of Report***
***End of Report***
***End of Report***

This is the code that I now have:


#!/bin/sh

myhome=/ebizImpact/ImpactServer-5_4/config/Cluster/DOCfrFTP

# Move the Original .doc Word reports in DOCfrFTP/BAK to a tran file
# Add an End of Report seperator between each report

for FILE in $myhome/BAK/*.doc; do
cat -q $myhome/BAK/$FILE >> $myhome/DOCfrFTP_`date +%Y%m%d`.doc.tran
echo "*** END OF REPORT ***" >> $myhome/DOCfrFTP_`date +%Y%m%d`.doc.tran
done
rm -f $myhome/BAK/*.doc


The code is pretty simple so you would think it would work. Anyway, thanks again in advance for any further suggestions.
Closed Thread

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 02:35 PM.


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