Help needed to validate and merge Two files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed to validate and merge Two files
# 1  
Old 06-02-2009
Java Help needed to validate and merge Two files

Hi.. I am new to unix !!!
Please help me in combining two files by validating the first column.
The files are tab limited !!!

I have a file which has the following contents...
DEPT1_BABYCARE 20 abce
DEPT2_PHARMACY 50 cdgde
DEPT3_WOMENS 75 jasjjas

I have another file which has the following contents
DEPT1_BABYCARE 30 50
DEPT2_PHARMACY 70 90
DEPT4_GROCERY 90 99 ( This line has to be removed as its not available in first file)

Now I have to combine both the files...
DEPT1_BABYCARE 20 abce 30 50
DEPT2_PHARMACY 50 cdgde 70 90
DEPT3_WOMENS 75 jasjjas NA NA

Please help ...
# 2  
Old 06-02-2009
Please search the forums first - there're numerous of similar threads.
# 3  
Old 06-02-2009
I am Unable to find a thread that suits my requirement... I want to validate a column and then merge... Please help...
# 4  
Old 06-02-2009
https://www.unix.com/shell-programmin...ing-files.html

Check this thread. It does what you want it to do
# 5  
Old 06-02-2009
Thanks Joe.... But this thread doesnt suit my requirement.. i tried it. Please help.....

-----Post Update-----

somebody
Please help...
# 6  
Old 06-02-2009
You could use the join command like this

Code:
 
join -a 1 -1 1 -2 1 -t" " -o 1.1 1.2 1.3 2.2 2.3 file1 file2

# 7  
Old 06-02-2009
If this is going to be routine, you are probably far better off using a database, also considering your data is tab delimited. Databases are more robust, especially when files get big. In such case, the problem boils down to reading in your data and getting the SQL for selection right.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Validate compressed files

Hi All, I have zip file that needs to be validated and checked for 5 times with sleep of 60 seconds. Some thing like below #!/bin/bash counter=1 while do curl -i -k -X GET `strings tmp.txt |grep Location| cut -f2 -d" "` -H "Authorization: Token $TOKEN" -o $zip_file ## this is... (6 Replies)
Discussion started by: Master_Mind
6 Replies

2. Shell Programming and Scripting

awk to compare files and validate order of headers

The below awk verifies the count and order of each text file in the directory. The script does execute and produce output, however the order of the headers are not compared to key. The portion in bold is supposed to do that. If the order of the headers in each text file is the same as key, then... (0 Replies)
Discussion started by: cmccabe
0 Replies

3. Shell Programming and Scripting

Validate input files daily

We have a job which we need to run on daily bases, before loading data in a table we need to validate whether the input file is received or not. Daily client will place the files in a particular path.Below files which I need to process for 04/01/2013(Load date).... (2 Replies)
Discussion started by: katakamvivek
2 Replies

4. Shell Programming and Scripting

Validate input files and update

We have a job which we need to run on daily bases, before loading data in a table we need to validate whether the input file is received or not.Inputfile formatsrc_sps_d_Call_Center_Reporting_yyyymmdd_01.dat SPS-Service nameYYYY-yearMM-MonthDD-dayLike above we will get n number of files for... (1 Reply)
Discussion started by: katakamvivek
1 Replies

5. Shell Programming and Scripting

[Validate] Script to remove files olderthan X days

Hi, I have written a small shell script to remove the files olderthan X days (say 30). But I not sure how it acts on the filesystem, as I am using rm. if then echo "##############################################" echo "Invalid no .of arguments\n" echo "Usage:\n$0 PATH... (6 Replies)
Discussion started by: karumudi7
6 Replies

6. Shell Programming and Scripting

Validate before moving files.

File Format dataline1,12,,,,; dataline2,24,,,; dataline3,12,,,,; dataline4,24,,,; COUNT=0004; Hi, I have source(/home/rgupta) and destination folders /home/rgupta/arch and /home/rgupta/err. Source folders has many files. I want to move the files from source to destination with some... (1 Reply)
Discussion started by: ravigupta2u
1 Replies

7. Shell Programming and Scripting

How to validate files after FTP

Hi, I have to write a script and the requirment where using ftp i need to get 8 files from a remote box to local. I know how how to ftp and do get. However i want do a validation after get. After geting for 8 files, i want to compare the size of the 8 files when it was in remote box with size... (6 Replies)
Discussion started by: tarakant
6 Replies

8. Shell Programming and Scripting

script needed to merge two files and report differences

Hello, I have two txt files that look like this: db.0.0.0.0: Total number of NS records = 1 db.127.0.0.0: Total number of NS records = 1 Total number of PTR records = 1 db.172.19.0.0: Total number of NS records = 1 Total number of PTR records = 3 db.172.19.59.0: Total... (8 Replies)
Discussion started by: richsark
8 Replies

9. Shell Programming and Scripting

sftp validate files before removal

I have a shell, which locks calls an expect script that connects to an sftp and downloads all files. I need it to then check each file in my directory and compare the sizes. If the file name and file size match, then delete the file on the server. Is this possible? :confused: (2 Replies)
Discussion started by: tariqjamal
2 Replies

10. Shell Programming and Scripting

sftp shell that will validate files

Hi. I've written a shell that will sftp about 5,000 to 10,000 files a day (they are small 200 byte files). Where I'm stuck at is that I need to not only copy those files from the ftp server, I also need to delete the files on the ftp server after they have been ftped BUT before they've been... (0 Replies)
Discussion started by: biglarrrr
0 Replies
Login or Register to Ask a Question