Bashing of records in different file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Bashing of records in different file
# 1  
Old 06-04-2014
Bashing of records in different file

Hi Everyone,

Good Day, I'm a newbie on scripting, I would like to seek you for assistance regarding on how to bash the 1st file into 2nd file and output the match record.

Sample:
Code:
File1.csv
JuanDelaCrus<tab>USA<tab>CANADA
TwoDelaCrus<tab>SG<tab>California

File2.csv
asdf<tab>qwerty<tab>33452
ThirdDelaCrus<tab>SK<tab>343544
JuanDelaCrus<tab>USA<tab>CANADA

The output will be(see below) since they are the same record in file1 and file2
JuanDelaCrus<tab>USA<tab>CANADA

i don't know if i used grep. sorry guys i'm still a newbie.

Please advise,

Thanks,
# 2  
Old 06-04-2014
?
Code:
grep -f File1.csv File2.csv > File3.csv

or just
Code:
grep -f File1.csv File2.csv

if you just want to see the output...
This User Gave Thanks to vbe For This Post:
# 3  
Old 06-04-2014
Quote:
Originally Posted by vbe
?
Code:
grep -f File1.csv File2.csv > File3.csv

or just
Code:
grep -f File1.csv File2.csv

if you just want to see the output...
Thank you very much Sir vbe, i though it will require a loop statement.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bashing of 2 files

Hi All, Seeking for your assistance on how to bash 2 files and then print if the condition met. Ex. file1.txt: Field1 Field2 Field 3 Field 4 usa <blank> <blank> INDIA file2.txt: Field1 Field2 Field 3 Field 4 canada jap INDIA utah... (7 Replies)
Discussion started by: znesotomayor
7 Replies

2. Shell Programming and Scripting

Separate records of a file on 2 types of records

Hi I am new to shell programming in unix Please if I can provide help. I have a file structure of a header record and "N" detail records. The header record will be the total number of detail records I need to split the file in 2: One for the header Another for all detail records Could... (1 Reply)
Discussion started by: jamcogar
1 Replies

3. Shell Programming and Scripting

Bashing of 2 Files

Hi Everyone, Seeking for your assistance on how to bash the file 1 to file 2 records and output the same records with specific field to display to file3. Example: Imagine we have many Files and records in File 1 and the File2 is only 1 file but many records. File1... (3 Replies)
Discussion started by: znesotomayor
3 Replies

4. UNIX for Dummies Questions & Answers

Bashing of Fields then append!

Hi All, I;m a newbie here, Seeking for your assistance regarding on how to bash the 6th and 7th fields of file2 into 2th and 3rd fields of file1 then add fields in the last line of file2 if it's match, if not they will only display the records. Ex. File1 a,1,2,b,c,d,e,USA... (5 Replies)
Discussion started by: nikka
5 Replies

5. Shell Programming and Scripting

Deleting duplicate records from file 1 if records from file 2 match

I have 2 files "File 1" is delimited by ";" and "File 2" is delimited by "|". File 1 below (3 record shown): Doc1;03/01/2012;New York;6 Main Street;Mr. Smith 1;Mr. Jones Doc2;03/01/2012;Syracuse;876 Broadway;John Davis;Barbara Lull Doc3;03/01/2012;Buffalo;779 Old Windy Road;Charles... (2 Replies)
Discussion started by: vestport
2 Replies

6. UNIX for Dummies Questions & Answers

Grep specific records from a file of records that are separated by an empty line

Hi everyone. I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this: ID: 20 Name: X Age: 19 ID: 21 Name: Z ID: 22 Email: xxx@yahoo.com Name: Y Age: 19 I want to grep records that... (4 Replies)
Discussion started by: Atrisa
4 Replies

7. Shell Programming and Scripting

Based on num of records in file1 need to check records in file2 to set some condns

Hi All, I have two files say file1 and file2. I want to check the number of records in file1 and if its atleast 2 (i.e., 2 or greater than 2 ) then I have to check records in file2 .If records in file2 is atleast 1 (i.e. if its not empty ) i have to set some conditions . Could you pls... (3 Replies)
Discussion started by: mavesum
3 Replies

8. UNIX for Dummies Questions & Answers

Use records from one file to delete records in another file

file_in_1: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 file_in_2: 9 10 11 12 21 22 23 24 1 2 3 4 17 18 19 20 file_out: (5 Replies)
Discussion started by: kenneth.mcbride
5 Replies

9. Shell Programming and Scripting

Count No of Records in File without counting Header and Trailer Records

I have a flat file and need to count no of records in the file less the header and the trailer record. I would appreciate any and all asistance Thanks Hadi Lalani (2 Replies)
Discussion started by: guiguy
2 Replies

10. UNIX for Dummies Questions & Answers

All right. ... (no Microsoft bashing, thanks)

First off, this is as much as I know about Unix: its an operating system. Now, I know it goes a tad deeper than that, so first off, what exactly is Unix? Next, im freakin sick of everything microsoft crashing on me, so Id like to make Unix my OS, but I dont want to lose anything but internet... (5 Replies)
Discussion started by: gc_wyo_dave
5 Replies
Login or Register to Ask a Question