Merging specifc lines of three files into one?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Merging specifc lines of three files into one?
# 1  
Old 02-13-2016
Merging specifc lines of three files into one?

Recall that nc-county-pop.dat has 100 lines, and each line corresponds to a county. The files girls.dat and boys.dat each has 50 lines. Assume that the girls come from the first 50 counties and each county has only one girl. That is the first girl comes from the first county, the second girl comes from the second county, and so on. Similarly, assume that the boys come from the last 50 counties and each county has only one boy. That is the first boy comes from the $51 county, the second boy comes from the $52 county, and so on.

Produce a file that has two columns, where the first column is the name of the girl/boy and the second column is the name of the county. The order of the names of girls, boys, and county names must be in the same order of their occurrence in the corresponding data files.

1. I thought the first file would be something like

Code:
join -1 1 -2 1 -t "#" -o '2.1 1.1' girls.dat nc-county-pop.dat


Last edited by Don Cragun; 02-13-2016 at 09:38 PM.. Reason: Add CODE AND ICODE tags.
# 2  
Old 02-13-2016
This sounds like a homework assignment. Homework and coursework questions can only be posted in the Homework & Coursework Questions forum and must include a completely filled out homework template that is included in the special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

If this is not a homework assignment, please explain the reason for doing this project and include more information, including, but not necessarily limited to:
  • the operating system you're using,
  • the shell you're using,
  • sample input data (in CODE tags), and
  • sample desired output data (in CODE tags).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check in a folder all files which doesnt have the specifc string?

I have a folder with 100s of dat files, with delimiter "|", in some files they didn't provide this delimiter. how to automatically check those list of files in a folder which doesnt have a delimiter or string this way "|" is it possible? Thank you very much for the helpful info. (3 Replies)
Discussion started by: cplusplus1
3 Replies

2. UNIX for Beginners Questions & Answers

Duplicate specifc lines in csv

Hi, I want to duplicate lines of a csv file with header if a column has multiple values. The csv uses semicolon as separator while multiple values are separated with comma. Only the type3 column can have multiple values. input: type1;type2;type3 a1;b1;x,y a2;b2;z output: a1;b1;x... (2 Replies)
Discussion started by: iz_82
2 Replies

3. Shell Programming and Scripting

Merging two files each contain 16 lakh lines on HP-UX 11.11 system

Hello All , I am trying to merge two files each contain 16 lakh lines ..My requirement is i have merge after every 14 lines of each file . Like from file1 14 lines then after after 14 lines form file2 ..so i wrote below script . It is working for small files ,but large files script not... (10 Replies)
Discussion started by: Phani369
10 Replies

4. Shell Programming and Scripting

Merging multiple lines to columns with awk, while inserting commas for missing lines

Hello all, I have a large csv file where there are four types of rows I need to merge into one row per person, where there is a column for each possible code / type of row, even if that code/row isn't there for that person. In the csv, a person may be listed from one to four times... (9 Replies)
Discussion started by: RalphNY
9 Replies

5. Shell Programming and Scripting

Merging multiple files using lines from one file

I have been working of this script for a very long time and I have searched the internet for direction but I am stuck here. I have about 3000 files with two columns each. The length of each file is 50000. Each of these files is named this way b.4, b.5, b.6, b.7, b.8, b.9, b.10, b.11, b.12... (10 Replies)
Discussion started by: iconig
10 Replies

6. Shell Programming and Scripting

Merging lines

Thanks it worked for me. I have one more question on top of that. We had few records which were splitted in 2 lines instead of one. Now i identified those lines. The file is too big to open via vi and edit it. How can i do it without opening the file. Suppose, I want line number 1001 & 1002 to... (2 Replies)
Discussion started by: Gangadhar Reddy
2 Replies

7. Shell Programming and Scripting

merging two .txt files by alternating x lines from file 1 and y lines from file2

Hi everyone, I have two files (A and B) and want to combine them to one by always taking 10 rows from file A and subsequently 6 lines from file B. This process shall be repeated 40 times (file A = 400 lines; file B = 240 lines). Does anybody have an idea how to do that using perl, awk or sed?... (6 Replies)
Discussion started by: ink_LE
6 Replies

8. Shell Programming and Scripting

Matching lines across multiple csv files and merging a particular field

I have about 20 CSV's that all look like this: "","","","","","","","","","","","","","","",""What I've been told I need to produce is the exact same thing, but with each file now containing the start_code from every other file where the email matches. It doesn't matter if any of the other... (1 Reply)
Discussion started by: Demosthenes
1 Replies

9. Shell Programming and Scripting

Merging files with AWK filtering and counting lines

Hi there, I have a couple of files I need to merge. I can do a simple merge by concatenating them into one larger file. But then I need to filter the file to get a desired result. The output looks like this: TRNH 0000000010941 ORDH OADR OADR ORDL ENDT 1116399 000000003... (2 Replies)
Discussion started by: Meert
2 Replies

10. UNIX for Dummies Questions & Answers

Merging lines into one

Hello. I would be very pleased if sb. help me to solve my problem. I've got a file with many non blank lines and I want to merge all lines into one not destroy the informations on them. I've tryed it with split and paste, tr, sed , but everything I've done has been wrong. I know about crazy... (8 Replies)
Discussion started by: Foxgard
8 Replies
Login or Register to Ask a Question