SOLVED: Join problem


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers SOLVED: Join problem
# 1  
Old 02-11-2011
SOLVED: Join problem

Hello,

Going through book, "Guide to UNIX Using Linux". I am doing one of the projects that has me writing scripts to join files. Here is my pnumname script and I am extracting the programmers names and numbers from the program file and redirecting the output to the file pnn. I then created a joinall script where I am trying to join the files pnn and pnumname and redirect the output to pactrep ( join -t: a1 -j1 1 -j2 1 pnn pnum > pactrep)When I run the script sh joinall and use less to display the contents of the redirected file pactrep, I get an error- join: extra operand `pnum'
Try `join --help' for more information....
I went to the man pages but I still (obvious) do not have a solid grasp. Thanks for the help in advance.
Code:
#=======================================================
# Script Name: pnumname
# By:          J.D.
# Date:        February 2011
# Purpose:     Extract Programmer Numbers and Names
#=======================================================
cut -d: -f1-4 programmer | sort -t: -k 1 | uniq > pnn
# The above cuts out fields 1 through 4.
# The output is piped to a sort by programmer number.
# The sorted output is piped to uniq to remove
# duplicates.
# Uniq redirects the output to pnn.

output file pnn results...
Code:
cat pnn
101:Johnson:John:K
102:King:Mary:K
103:Brown:Gretchen:K
104:Adams:Betty:C
105:Utley:Amos:V
106:Wilson:Patricia:B
107:Culligan:Thomas:F
108:Mitchell:Hillary:N
109:Arbuckle:Margaret:F
110:Ford:Terrence:H
111:Greene:Sarah:L
112:Rose:Richard:P
113:Daniels:Allan:S
114:Edwards:George:J

joinall script
Code:
#=========================================================
# Script Name: joinall
# By:          J.D.
# Date:        February 2011
# Purpose:     Join pnum and pnn to create a report file
#==========================================================
# Join the file including the unassigned programmers.
# You do this by placing the programmer names (pnn) file,
# forst, in the join sequence.
#==========================================================
join -t: a1 -j1 1 -j2 1 pnn pnum > pactrep

---------- Post updated at 10:21 AM ---------- Previous update was at 09:19 AM ----------

forget it, I figured it out, I am so stupid. minus a1 -a1

Last edited by radoulov; 02-11-2011 at 01:18 PM.. Reason: use code tags please
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with Join Command

I have 2 files. File 1 is a daily file with only a bunch of IDs and a date column. File 2 has all the dump of IDs and their respective cost. I basically want an inner join. When I am picking a few rows from these files and joining, they work perfectly fine. But when I join the full files together,... (13 Replies)
Discussion started by: Varshha
13 Replies

2. UNIX for Dummies Questions & Answers

Weird problem with join command

I have a weird issue going on with the join command... I have two files I am trying to join...here is a line from each file with the important parts marked in red: file1: /groupspace/ccops/cmis/bauwkrcn/commsamp_20140315.txt,1 file2:... (3 Replies)
Discussion started by: dbiggied
3 Replies

3. UNIX for Dummies Questions & Answers

how to join two files using "Join" command with one common field in this problem?

file1: Toronto:12439755:1076359:July 1, 1867:6 Quebec City:7560592:1542056:July 1, 1867:5 Halifax:938134:55284:July 1, 1867:4 Fredericton:751400:72908:July 1, 1867:3 Winnipeg:1170300:647797:July 15, 1870:7 Victoria:4168123:944735:July 20, 1871:10 Charlottetown:137900:5660:July 1, 1873:2... (2 Replies)
Discussion started by: mindfreak
2 Replies

4. UNIX for Dummies Questions & Answers

Problem when using join command

Dear all, I have two files (each only contains 1 column) as attached. I want to combined the two files and only show the common records in both files. But when I use join command only the last row was combined. Anyone know what is the problem? I don't know how to write the correct code to only... (2 Replies)
Discussion started by: forevertl
2 Replies

5. UNIX for Dummies Questions & Answers

problem with join

So I want to join two files that have a lot of rows The file named gen1 has 2 columns: head gen1 1008567 0.4026931012 1119535 0.7088912314 1120590 0.7093805634 1145994 0.7287952590 1148140 0.7313924434 1155173 0.7359550430 1188481 0.7598914553 1201155 0.7663406553 1206921... (2 Replies)
Discussion started by: peanuts48
2 Replies

6. Homework & Coursework Questions

How join works and the specific parameters to my problem?

1. The problem statement, all variables and given/known data: I have two files created from extracting data off of two CSV files, one containing class enrollment on a specific quarter and the other containing grades for that specific quarter. The Enrollment file generated contains course name,... (11 Replies)
Discussion started by: Lechnology
11 Replies

7. UNIX for Dummies Questions & Answers

join -t problem (newbie)

Been tearing my hair out trying to work out how to make the -t option in the join command work. Joining two files on col 1; columns in both files are separated by tabs. file1: 2010/02/01-00:00 10.63 2010/02/01-00:06 10.63 2010/02/01-00:12 10.61 2010/02/01-00:18 10.58 (there are LOTS... (4 Replies)
Discussion started by: lobsterman
4 Replies

8. UNIX for Dummies Questions & Answers

Join 2 files with multiple columns: awk/grep/join?

Hello, My apologies if this has been posted elsewhere, I have had a look at several threads but I am still confused how to use these functions. I have two files, each with 5 columns: File A: (tab-delimited) PDB CHAIN Start End Fragment 1avq A 171 176 awyfan 1avq A 172 177 wyfany 1c7k A 2 7... (3 Replies)
Discussion started by: InfoSeeker
3 Replies

9. Shell Programming and Scripting

Problem with Join command

Hi guyz Excuse me for posting simple question I tried join and sort and other perl commands but failed I have 2 files. 1st file contain single column with around 6000 values (rows). Second file contain 2 columns 1st column is the same column (in 1st file) but randomly ordered and second... (5 Replies)
Discussion started by: repinementer
5 Replies

10. Shell Programming and Scripting

A join problem?

Hi everybody, I am hoping somebody here will be either be able to solve my troubles or at least give me a push in the right direction :) . I am developing a shell script to read in 4 different files worth of data that each contain a list of: username firstname secondname group score I... (2 Replies)
Discussion started by: jamjamjammie
2 Replies
Login or Register to Ask a Question