Find and Merge files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find and Merge files
# 1  
Old 05-29-2005
Find and Merge files

Hi,

I am relatively new to unix and I need to write a simple script to monitor a log directory. Being adventurous, I intend to pick up a couple of scripting to make my work more efficient.

I need to
1) merge files with names that starts with the same date
Example:
12052005.2alarm
12052005.3alarm
:
:
2) sort and grab relevant rows and resort them into a file in a prefixed time every day
3) automate the daily process as a daemon process ?is this the correct term?
4) A second daemon that merge the files from above steps weekly

Assistance required to
1) how to find files and merge the relevant files together?
I have thought of a solution but do not know how to carry it out as a script
#search for files
find date+*
#store the file names
???
#carry out a append of the files
cp ??? >> 'date'

2) I have completed and tested this section, I had used GREP then a UNIQ to acomplish the task

3) How to write a script that will carry out a certain function at the predefined interval? (daily at XXXXh and weekly at mon XXXXh)

4) I believe that the solution for 3 can be altered for this function

Thanks a lot
# 2  
Old 05-29-2005
Quote:
Originally Posted by seongyin
Hi,
1) how to find files and merge the relevant files together?
Something like
find . -name "`date +%d%m%Y*alarm`" -exec cat {} \; >> /path/to/outputfile
(for files with todays date)

find . -name "mydatehere*alarm" -exec cat {} \; >> /path/to/outputfile
(for files with any date you specify - look into GNU date's -d option)
Quote:
2) I have completed and tested this section, I had used GREP then a UNIQ to acomplish the task
Good for you Smilie
Quote:
3) How to write a script that will carry out a certain function at the predefined interval? (daily at XXXXh and weekly at mon XXXXh)
4) I believe that the solution for 3 can be altered for this function
Write your script, then read the cron manual page.

Cheers
ZB
# 3  
Old 05-29-2005
Thanks. Let me test it out

Thanks again
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find matched patterns in a column of 2 files with different size and merge them

Hi, i have input files like below:- input1 Name Seq_ID NewID Scores MT1 A0QZX3 1.65 277.4 IVO A0QZX3 1.65 244.5 HPO A0QZX3 1.65 240.5 RgP A0Q3PP 5.32 241.0 GX1 LPSZ3S 96.1 216.9 MEL LPSS3X 4.23 204.1 LDD LPSS3X 4.23 100.2 input2 Fac AddName NewID ... (9 Replies)
Discussion started by: redse171
9 Replies

2. Shell Programming and Scripting

Merge files and generate a resume in two files

Dear Gents, Please I need your help... I need small script :) to do the following. I have a thousand of files in a folder produced daily. I need first to merge all files called. txt (0009.txt, 0010.txt, 0011.txt) and and to output a resume of all information on 2 separate files in csv... (14 Replies)
Discussion started by: jiam912
14 Replies

3. Shell Programming and Scripting

How to merge two files?

Hi Gurus, I have two files as below file1 abc cde cdd cdf file2 123 234 345 456 I want to get abc 123 cde 234 cdd 345 (3 Replies)
Discussion started by: ken6503
3 Replies

4. Shell Programming and Scripting

Merge files

a.txt id name subject 12 aaa History 23 bbb Science 45 ccc Zoology b.txt id layer LayerNo 12 xxx12 1 23 yyy23 2 23 lll23 3 45 xxx45 1 45 yyy45 2 45 lll45 3 i have file a.txt which is parent file and another children file b.txt . Both files are linked together by common field... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

5. Shell Programming and Scripting

Find duplicates in column 1 and merge their lines (awk?)

Hi, I have a file (sorted by sort) with 8 tab delimited columns. The first column contains duplicated fields and I need to merge all these identical lines. My input file: comp100002 aaa bbb ccc ddd eee fff ggg comp100003 aba aba aba aba aba aba aba comp100003 fff fff fff fff fff fff fff... (5 Replies)
Discussion started by: falcox
5 Replies

6. Shell Programming and Scripting

Checking in a directory how many files are present and basing on that merge all the files

Hi, My requirement is,there is a directory location like: :camp/current/ In this location there can be different flat files that are generated in a single day with same header and the data will be different, differentiated by timestamp, so i need to verify how many files are generated... (10 Replies)
Discussion started by: srikanth_sagi
10 Replies

7. Shell Programming and Scripting

How can i merge these two files into several...

Given are File A and File B File A has for example 5 lines: AAA BBB CCC DDD EEE File B has 3 lines: 111 222 333 How can i merge A and B into: 111 222 333 AAA (first line from A) then a new file: (4 Replies)
Discussion started by: Y-T
4 Replies

8. Shell Programming and Scripting

To find and merge two files

Hi All, I have two files file1 and file2 as below. cat file1 200000040;20.0 200000020;40.0 200000060;10 200000100;.0.5 ---------------- cat file2 200000020 200000100 200000040 200000060 I want to merge... (4 Replies)
Discussion started by: girish.raos
4 Replies

9. Shell Programming and Scripting

Merge files of differrent size with one field common in both files using awk

hi, i am facing a problem in merging two files using awk, the problem is as stated below, file1: A|B|C|D|E|F|G|H|I|1 M|N|O|P|Q|R|S|T|U|2 AA|BB|CC|DD|EE|FF|GG|HH|II|1 .... .... .... file2 : 1|Mn|op|qr (2 Replies)
Discussion started by: shashi1982
2 Replies

10. Shell Programming and Scripting

help in merge files

I have created these files in a particular directory a_1.txt a_2.txt ... .. a_n.txt Each file has a single line. I want to write a output file a.txt, which will have concantated value of string from all the files. which utility should i use. copy, cat or paste???? Can anyone help... (5 Replies)
Discussion started by: u263066
5 Replies
Login or Register to Ask a Question