How to merge the multiple data files as a single file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to merge the multiple data files as a single file?
# 1  
Old 09-08-2014
Oracle How to merge the multiple data files as a single file?

Hi Experts,

I have created multiple scripts and send the output to new file, getting this output to my mailbox on daily basis.

I would like to send the all outputs to a single file, need to merge all file outputs on a single file.

For example,

Created script for
Code:
df -h > df.doc
grep -i "error" /var/adm/messages > error.doc

Here i want to merge these outputs into a single file, i don't wanna get two emails for this outputs separately.

Server - Solaris
Shell - Bash

If any questions please let me know.

Regards,
Sri

Last edited by Don Cragun; 09-08-2014 at 04:31 AM.. Reason: Add CODE tags.
# 2  
Old 09-08-2014
Hi Sri,

Not completly sure about your requirement, but in place of 2 files you can simply append the errors into the same file in which you are saving the df -h command, then you can send the data into the email. It will be like as follows.

Code:
df -h > df_and_errors.doc
grep -i "error" /var/adm/messages >> df_and_errors.doc

If you have any queries, kindly let us know the complete details for same, so that we can try to help you more on same.

Thanks,
R. Singh
# 3  
Old 09-08-2014
Hi Ravinder,

Yes, you are right. This simple append command will merge the details in same server, i would like to know how to merge two .doc files from different servers.

For example,

df -h > host1.doc --> from host1
df -h > host2.doc --> from host2

Now i want to merge these different server details into single file then need to receive it by mail.

Regards,
Sri

Last edited by Don Cragun; 09-08-2014 at 04:32 AM.. Reason: Add ICODE tags.
# 4  
Old 09-08-2014
There are several options. Give us more context like
- where and how are the scripts run?
- do you have a network file system in place?
- how are those mails being sent?
# 5  
Old 09-08-2014
Hi RudiC,

I am doing same daily monitoring on 3 servers (solaris), created simple script to get this monitoring results by email also updated on cron job to receive this on daily basis.

Now i am receiving daily 3 mails for each servers.

Code:
df | tee df.doc---> one mail

Code:
top | tee top.doc --->2nd mail

Code:
prstat -a | tee prstat.doc --->3rd mail

Instead of receiving 3 mails for each servers, i would like to merge these all and need to receive only single mail for each server.

Also if possible want to merge all 3 server mails as single mail.

Regards,
Sri

---------- Post updated at 05:49 AM ---------- Previous update was at 04:10 AM ----------

Oops, its not working on bash shell.

df -h > df_and_errors.doc grep -i "error" /var/adm/messages >> df_and_errors.doc First df -h only works here.

Any suggestions why its not working on bash shell!!!

Regards,
SRi

Last edited by seenuvasan1985; 09-08-2014 at 07:51 AM.. Reason: added code
# 6  
Old 09-08-2014
You did not answer either of my questions. Show us the scripts. Give us more context.
# 7  
Old 09-08-2014
Oops, its not working on bash shell.

df -h > df_and_errors.doc
grep -i "error" /var/adm/messages >> df_and_errors.doc

First df -h only works here.

Any suggestions why its not working on bash shell!!!

Regards,
SRi

---------- Post updated at 05:56 AM ---------- Previous update was at 05:52 AM ----------

Yes, NFS in place.

Mail receiving from below script and updated on cronjob to run on perticular time.
Code:
uuencode Performance.doc Performance.doc | mailx -s "BV01Monitoring_df" sri@gmail.com

Script runs on bash shell
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merge multiple lines into a single line

Hi all, I'm relatively new to scripting, I can do pretty basic things. I have a daily log file that looks like: timestamp=2017-06-28-01.01.35.080576; event status=0; userid=user1; authid=user1; application id=10.10.10.10.11111.12345678901; application name=GUI; ... (29 Replies)
Discussion started by: dwdnet
29 Replies

2. Shell Programming and Scripting

Splitting a single file to multiple files

Hi Friends , Please guide me with the code to extract multiple files from one file . The File Looks like ( Suppose a file has 2 tables list ,column length may vary ) H..- > File Header.... H....- >Table 1 Header.... D....- > Table 1 Data.... T....- >Table 1 Trailer.... H..-> Table 2... (1 Reply)
Discussion started by: AspiringD
1 Replies

3. Shell Programming and Scripting

Perl script to Merge contents of 2 different excel files in a single excel file

All, I have an excel sheet Excel1.xls that has some entries. I have one more excel sheet Excel2.xls that has entries only in those cells which are blank in Excel1.xls These may be in different workbooks. They are totally independent made by 2 different users. I have placed them in a... (1 Reply)
Discussion started by: Anamika08
1 Replies

4. Shell Programming and Scripting

Merge the multiple text files into one file

Hi All, I am trying to merge all the text files into one file using below snippet cat /home/Temp/Test/Log/*.txt >> all.txt But it seems it is not working. I have multiple files like Output_ServerName1.txt, Output_ServreName2.txt I want to merge each file into one single file and... (6 Replies)
Discussion started by: sharsour
6 Replies

5. UNIX for Dummies Questions & Answers

Need help combining txt files w/ multiple lines into csv single cell - also need data merge

:confused:Hello -- i just joined the forums. I am a complete noob -- only about 1 week into learning how to program anything... and starting with linux. I am working in Linux terminal. I have a folder with a bunch of txt files. Each file has several lines of html code. I want to combine... (2 Replies)
Discussion started by: jetsetter
2 Replies

6. Shell Programming and Scripting

Merge the data from two servers into a single file

Hi All, Need your inputs for the below. I have 2 different servers 611 & 610, where i would be running two scripts. And would would be running one script from 611 at every 4 hours to merge the data from the 2 servers into 2 files and send a mail. so below is the code snippet for 611: ... (3 Replies)
Discussion started by: ss_ss
3 Replies

7. Shell Programming and Scripting

Combine Multiple Files into Single One File One after other

I am trying to combine 4 .dat files into one single Output file Inputs are:- file123.dat, file256.dat, file378.dat & file490 Expected Output:- FileName=file1 {text from file1} EOF {blank line} FileName=file2 {text from file2} EOF {blank line} FileName=file3 {text from file3} EOF... (4 Replies)
Discussion started by: lancesunny
4 Replies

8. Shell Programming and Scripting

How to merge multiple rows into single row if first column matches ?

Hi, Can anyone suggest quick way to get desired output? Sample input file content: A 12 9 A -0.3 2.3 B 1.0 -4 C 34 1000 C -111 900 C 99 0.09 Output required: A 12 9 -0.3 2.3 B 1.0 -4 C 34 1000 -111 900 99 0.09 Thanks (3 Replies)
Discussion started by: cbm_000
3 Replies

9. Shell Programming and Scripting

Merge multiple files found in config file

I have a config file with a bunch of these type of blocks: <concat destfile="${standard.js.file}" append="true"> <filelist dir="${js.dir}/foo" files="foo.js, foo2.js"/> <filelist dir="${js.dir}" files="foo3.js"/> <filelist dir="${js.dir}/bar/js"... (11 Replies)
Discussion started by: Validatorian
11 Replies

10. Shell Programming and Scripting

Have several text files and want to merge into a single

Hello, I have several files that begin with db. in my directory and I would like to first take it from a specific word starting from $TTL until the end of the contents then do the same all the way down the directory then merge them into one txt file. Is this possible? I am using cygwin with... (4 Replies)
Discussion started by: richsark
4 Replies
Login or Register to Ask a Question