08-11-2010
Script for merging files
I am facing a strange situation where I need to collect logs and consolidate them.
All logs are under say /tmp/useless and all logs are under subdir of the form IPaddresses_x_y
eg: /tmp/useless/105.52.34.246_3_1
/tmp/useless/105.52.1.118_0_10
There are several logs under each subdir and I want logs named interested.txt. I need to find them, consolidate them in 1 big log. easy enough. BUT there is no ID inside each log and so I need to insert the IP address from the subdir name at the top of each log before appending . I know I can get IP addresses by using cut, store them and use a loop. Not sure if this is the right approach. Any pointer is appreciated.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi I have a requirement like this.
I have two files
This is how data1.txt looks:
EI3171280 38640658501 NENN2005-12-129999-12-312005-12-12HALL NANCY 344 CHENEY HIGHWAY ... (4 Replies)
Discussion started by: venommaker
4 Replies
2. Shell Programming and Scripting
Hi,
I have got two files
1.txt
1111|apple|
2222|orange|
2.txt
1111|1234|000000000004356|
1111|1234|000000001111|
1111|1234|002000011112|
2222|5678|000000002222|
2222|9102|000000002222|
I need to merge these two so that my out put looks like below:
Search code being used should be... (4 Replies)
Discussion started by: jisha
4 Replies
3. Shell Programming and Scripting
i would like to merge two files that have the same format but have different data.
i would like to create one output file that contains information from both the original files.:rolleyes: (2 Replies)
Discussion started by: joe black
2 Replies
4. Shell Programming and Scripting
Hi,
I want to merge the two files on the basis of columns like...
file 1
Data Key
A 12
B 13
file2
Data Value
A A1
A A2
B B1
B B2 (5 Replies)
Discussion started by: clx
5 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I have two files a.txt and b.txt.
a.txt
1
2
3
4
b.txt
a
b
c
d
e
I want to generate a file c.txt by merging these two file and the resultant file would contain
c.txt
1 (4 Replies)
Discussion started by: siba.s.nayak
4 Replies
6. Shell Programming and Scripting
:::::::::
::FileA::
:::::::::
A1-------A2--------A3---A4---A5--
=================================
AC5VXVLT-XX----------------------
B57E434--XXXX1-----MMMM-ZZZ--111-
C325G20--XXXXX3----CCCC------3332
DC35S51--XXXXY1----DDDD------44X-
DC35S52--XXXXY2----DDDD------44Y-... (5 Replies)
Discussion started by: lordsmiter
5 Replies
7. Shell Programming and Scripting
Hello,
I am trying to merge data from two text files. One file (File1) contains a listing of data which includes the trial number in Column 5, while the other text file (File2) contains what category the trial belongs to.
Here is a snippet of what File1 looks like.
1 Arrow_ST 9.738 0.905... (2 Replies)
Discussion started by: Jahn
2 Replies
8. Shell Programming and Scripting
Hi all
Need little help from you
my aim is like merging the output of 6 files (log_files)
And merge it into the one master file
tell me the script for this
please
thanks in advance
Please reply in mail if possible
<email removed>
Regards:
zimmy (1 Reply)
Discussion started by: zimmyyash
1 Replies
9. Shell Programming and Scripting
Guys,
I am having little problem with getting a daily report!
The daily process that I do is as follows
1. Unload Header for the report from the systables to one unl file, say Header.unl
2. Unload the data from the required table/tables to another unl file, say Data.unl
3. Send a... (2 Replies)
Discussion started by: PikK45
2 Replies
10. Shell Programming and Scripting
I have the urge to merge some files using unix shell script but I'm very new using this language and I haven't succeeded yet.
The requirement is to merge the header, body and footer into one file with the name "ANY-NAME" in below example. To identify which files should be merged, I have flagged... (9 Replies)
Discussion started by: black_soul
9 Replies
LEARN ABOUT DEBIAN
mergelogs
MERGELOGS(1) General Commands Manual MERGELOGS(1)
NAME
mergelogs - merge and consolidate web server logs
SYNOPSIS
mergelogs -p penlog [-c] [-d] [-j jitter] [-t seconds] server1:logfile1 [server2:logfile2 ...]
EXAMPLES
mergelogs -p pen.log 10.0.0.1:access_log.1 10.0.0.2:access_log.2
mergelogs -p pen.log 10.0.18.6:access_log-10.0.18.6 10.0.18.8:access_log-10.0.18.8
DESCRIPTION
When pen is used to load balance web servers, the web server log file lists all accesses as coming from the host running pen. This makes it
more difficult to analyze the log file.
To solve this, pen creates its own log file, which contains the real client address, the time of the access, the target server address and
the first few bytes of the requests.
Mergelogs reads pen's log file and the log files of all load balanced web servers, compares each entry and creates a combined log file that
looks as if the web server cluster were a single physical server. Client addresses are replaced with the real client addresses.
In the event that no matching client address can be found in the pen log, the server address is used instead. This should never happen, and
is meant as a debugging tool. A large number of these indicates that the server system date needs to be set, or that the jitter value is
too small.
You probably don't want to use this program. Penlog is a much more elegant and functional solution.
OPTIONS
-c Do not cache pen log entries. The use of this option is not recommended, as it will make mergelogs search the entire pen log for
every line in the web server logs.
-d Debugging (repeat for more).
-p penlog
Log file from pen.
-j jitter
Jitter in seconds (default 600). This is the maximum variation in time stamps in the pen and web server log files. A smaller value
will result in a smaller pen log cache and faster processing, at the risk of missed entries.
-t seconds
The difference in seconds between the time on the pen server and UTC. For example, this is 7200 (two hours) in Finland.
server:logfile
Web server address and name of log file.
AUTHOR
Copyright (C) 2001-2003 Ulric Eriksson, <ulric@siag.nu>.
SEE ALSO
pen(1), webresolve(1), penlog(1), penlogd(1)
LOCAL MERGELOGS(1)