Weird problem with join command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Weird problem with join command
# 1  
Old 03-17-2014
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:
/groupspace/ccops/cmis/bauwkrcn/commsamp_20140315.txt,10,BAU_Work_Recon,Mainframe-NDM

I do a join -t, on these two files and this is my output:
,1roupspace/ccops/cmis/bauwkrcn/commsamp_20140315.txt,10,BAU_Work_Recon,Mainframe-NDM

For some reason, it is joining the two files, but in the output, it is removing the last field of the first file and actually overwriting the beginning of the joined line with it. The files are properly sorted and uniq'd before the join. Any idea what the heck is going on here?
This User Gave Thanks to dbiggied For This Post:
# 2  
Old 03-17-2014
One thing that comes to mind is the possibility for embedded <CR> and/or <LF> characters.
Can you create simple one-line files (manually typed, or carefully cut/paste) and verify that this is not an issue?
These 2 Users Gave Thanks to joeyg For This Post:
# 3  
Old 03-17-2014
That was exactly it...one of my two files had the ^M characters...I removed them and it works perfectly. Sometimes it's the simple things that go overlooked!
# 4  
Old 03-18-2014
Hi,

I was facing the exact same problem. After running dos2unix on my input files it was sorted.

Last edited by ni2; 03-18-2014 at 08:42 AM.. Reason: Grammar?
 
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. Shell Programming and Scripting

Weird awk problem

Hi, I have a simple awk script: BEGIN{} { $a=$2-$1; print $a } END{if(NR==0){ print "0" } } to which I provide the following input 2.9 14 22.2 27 (4 Replies)
Discussion started by: jamie_123
4 Replies

3. UNIX for Dummies Questions & Answers

How to use the the join command to join multiple files by a common column

Hi, I have 20 tab delimited text files that have a common column (column 1). The files are named GSM1.txt through GSM20.txt. Each file has 3 columns (2 other columns in addition to the first common column). I want to write a script to join the files by the first common column so that in the... (5 Replies)
Discussion started by: evelibertine
5 Replies

4. 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

5. 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

6. UNIX for Dummies Questions & Answers

Weird problem with cp command on a Synology

Hi. First post, and Linux newbie, so maybe I'm missing something obvious: I have a Synology NAS that is run by a Linux distribution (which?). I have had an external hard drive connected to the NAS for making backups using Synology's backup application Time Backup. Time Backup is based on... (3 Replies)
Discussion started by: Pokersut
3 Replies

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

8. Shell Programming and Scripting

join (pls help on join command)

Hi, I am a new learner of join command. Some result really make me confused. Please kindly help me. input: file1: LEO oracle engineer 210375 P.Jones Office Runner ID897 L.Clip Personl Chief ID982 S.Round UNIX admin ID6 file2: Dept2C ID897 6 years Dept5Z ID982 1 year Dept3S ID6 2... (1 Reply)
Discussion started by: summer_cherry
1 Replies

9. Solaris

Weird crontab problem

Greetings To All! I am running Solaris 10 in a sparc environment. Here is the deal: In /var/spool/cron/crontabs, there is a cron user named "sys". If I do a crontab -l sys, it returns: # 0 * * * 0-6 /usr/lib/sa/sa1 # 20,40 8-17 * * 1-5 /usr/lib/sa/sa1 # 5 18 * * 1-5 /usr/lib/sa/sa2... (8 Replies)
Discussion started by: RobSand
8 Replies

10. UNIX for Dummies Questions & Answers

Weird Problem???

I have a problem I don't understand... I am trying to declare a variable, and then output the results of that variable, couldn't be simpler #!/bin/ksh VAR='Oranges' if then echo "Found Lemons" elif then echo "Found Oranges" fi The output shouold clearly be "Found Oranges", but... (2 Replies)
Discussion started by: danhodges99
2 Replies
Login or Register to Ask a Question