Script for merging files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for merging files
# 1  
Old 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.
# 2  
Old 08-11-2010
Code:
cd /tmp/useless
more */interested.txt > consolidated.log

This User Gave Thanks to binlib For This Post:
# 3  
Old 08-11-2010
wow! this is a simpel neat solution. Can I prevent the file name being printed ? I just need the dir name
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merging Files in UNIX shell script

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

2. Shell Programming and Scripting

Merging two files

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

3. Shell Programming and Scripting

Script for merging six files into one

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

4. Shell Programming and Scripting

AWK Script For Merging Text Files

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

5. Shell Programming and Scripting

Help with merging 2 files into 1

::::::::: ::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

6. UNIX for Dummies Questions & Answers

Merging two files

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

7. Shell Programming and Scripting

merging of files.

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

8. Shell Programming and Scripting

Help with merging files

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

9. Shell Programming and Scripting

Merging 2 files

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

10. UNIX for Dummies Questions & Answers

Merging two files

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
Login or Register to Ask a Question