Sponsored Content
Full Discussion: Join not working properly
Top Forums Shell Programming and Scripting Join not working properly Post 302879878 by ritakadm on Monday 16th of December 2013 09:51:27 AM
Old 12-16-2013
Ok, I used the code removing a $n from line 4,
Code:
awk     'NR==FNR        {T[$1]=($1="")$0; next}                         
                                        {C=split ($3,I,",")                         
 n=NF+1                          for (i=1; i<=C; i++) $n=($n?",":"")T[I[i]]}       
   1        
 ' /tmp/mt4.genenames.txt file1

The output doesnt pick up anything from genenames, it is the same as the input.

Code:
#   awk     'NR==FNR        {T[$1]=($1="")$0; next}
>                           {
>                           C=split ($3,I,",")
>                        n = NF+1
>                            for (i=1; i<=C; i++) $n=($n?",":"")T[I[i]]}
>            1
>         ' mt4.genenames.sorted.txt file1 | head
XLOC_048267 XLOC_048267 Medtr0001s0120 scaffold0001:49523-50287 q1 q2 OK 1.84679 0 -inf nan 5e-05 0.000126299 yes up
XLOC_048258 XLOC_048258 Medtr0001s0190 scaffold0001:64218-69070 q1 q2 OK 3.61301 0 -inf nan 5e-05 0.000126299 yes up
XLOC_048271 XLOC_048271 Medtr0001s0430 scaffold0001:188781-195705 q1 q2 OK 9.48928 3.76233 -1.33467 -4.06109 5e-05 0.000126299 yes up
XLOC_048260 XLOC_048260 Medtr0001s0490 scaffold0001:397820-401891 q1 q2 OK 10.303 4.14216 -1.31462 -3.77643 5e-05 0.000126299 yes up
XLOC_048263 XLOC_048263 Medtr0001s0570 scaffold0001:430832-437206 q1 q2 OK 7.21593 4.49932 -0.681479 -2.09584 0.00025 0.00057981 yes up
XLOC_048274 XLOC_048274 Medtr0001s0660 scaffold0001:502646-507542 q1 q2 OK 17.1506 2.11969 -3.01634 -7.77595 5e-05 0.000126299 yes up
XLOC_048321 XLOC_048321 Medtr0002s0270 scaffold0002:187389-188523 q1 q2 OK 0.232771 4.20249 4.17426 5.6741 0.0001 0.000244358 yes down
XLOC_048337 XLOC_048337 Medtr0002s0900 scaffold0002:341925-343403 q1 q2 OK 69.3725 28.7422 -1.27119 -4.90762 5e-05 0.000126299 yes up
XLOC_048340 XLOC_048340 Medtr0002s1060 scaffold0002:400363-401875 q1 q2 OK 1.527 160.669 6.71725 14.7088 5e-05 0.000126299 yes down
XLOC_048308 XLOC_048308 Medtr0002s1200 scaffold0002:454553-457418 q1 q2 OK 11.0499 0.148847 -6.21406 -6.09651 0.00165 0.00334041 yes up

Something is missing in the code in this line, after the second $n
Code:
for (i=1; i<=C; i++) $n=$n($n?",":"")T[I[i]]}


Last edited by ritakadm; 12-16-2013 at 12:14 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Keyboard not working properly...

Hello Again, Those that have noticed my earlier posts will know that I have succesfully installed Solaris 8 onto my pc. I haven't been able to get x-server working (i think it doesn't like my video card) though I've been able to log into root (with a bit of help from unix forums :o ) and have... (2 Replies)
Discussion started by: timresh
2 Replies

2. Programming

y is this not working properly?

#include <stdio.h> #include <sys/types.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> struct stat s; main() { char c; if (fork()==0) { system("clear"); do { printf("myAI\\>§ "); scanf("%s",c); if(stat(c,&s)>-1) {... (3 Replies)
Discussion started by: C|[anti-trust]
3 Replies

3. HP-UX

FC card not working properly

Hi I've a problem with Hp-ux 11.11 9000/800/rp3440 system. Already the software for driver & its patch are loaded for HBA Fibrechannel card, but still the fibrechannel card is showing the status "Unclaimed" . What will be reason for this? How to get the status "Claimed" ? Pl. help me out.... (4 Replies)
Discussion started by: Mike1234
4 Replies

4. Shell Programming and Scripting

\n not working properly

Hi all, I'm trying to generate a series of txt files starting from a plain csv file part of my code: #!/bin/ksh INSTALLDIR=/Users/ME/Installdir CSV=CSV.csv TMP=/tmp/$(basename $0).txt tr -s "\r" "\n" < /$INSTALLDIR/$CSV > $TMP function Makefiles { printf '%24s:%30s\n' "sometext"... (1 Reply)
Discussion started by: Jive Spector
1 Replies

5. UNIX for Advanced & Expert Users

Sendmail is not working properly

Hi All, Can any one help me to solve the issue. The Issue is, i have started the sendmail service on my RHEL 4 update 6 box, I am able to send the mail from my box to almost all of the Email Id's except few. Exampe, test mail. . Output is :the message is sent. now if I send the... (2 Replies)
Discussion started by: akhtar.bhat
2 Replies

6. Shell Programming and Scripting

mailx not working properly

I am using mailx command in my script to attach a file and send an email. I need to attach a csv file and send email to a mail id - I am using uuencode output.csv output.csv | mailx -s "test mail" xyz@abc.com This will send a mail with scrambled text in body. am i missing something ?... (4 Replies)
Discussion started by: Sriranga
4 Replies

7. Linux

rexec not working properly

Hi, I am trying to enable rexec to automate certain tasks(it has to be rexec, not ssh or any other due to the system environment), so after switching to linux, I followed the certain instructions that were laid out in the web. My operating system is fedora 17, so I first installed the... (1 Reply)
Discussion started by: wringer
1 Replies

8. UNIX for Dummies Questions & Answers

~c is not working properly with -r option

Hi There, --------- file1 ------- ~c asd@ac.com -------------- Now i am using below command cat file1|mailx -s " testing" -r " My Name" abc@tech.com (3 Replies)
Discussion started by: Tapan Sharma
3 Replies

9. Shell Programming and Scripting

Why is sort not working properly here ?

Platform: RHEL 5.4 In the below text file I have strings like following. $ cat /tmp/mytextfile.txt DISK1 DISK10 DISK101 DISK102 DISK103 DISK104 DISK105 DISK106 DISK107 DISK108 DISK109 DISK110 DISK111 DISK112 DISK113 DISK114 (8 Replies)
Discussion started by: kraljic
8 Replies

10. Shell Programming and Scripting

Expansion not working properly

I'm using an Ubuntu machine and expansion is not working properly. What would cause this? Do I need to check for any particular bash packages? $ ipcs -m | grep $USER | awk '{printf "%s ",$2}' $ ipcs -m | grep UNF | awk '{printf "%s ",$2}' 294912 1048577 425986 688131 786436 1245189... (14 Replies)
Discussion started by: cokedude
14 Replies
JOIN(1) 						    BSD General Commands Manual 						   JOIN(1)

NAME
join -- relational database operator SYNOPSIS
join [-a file_number | -v file_number] [-e string] [-o list] [-t char] [-1 field] [-2 field] file1 file2 DESCRIPTION
The join utility performs an ``equality join'' on the specified files and writes the result to the standard output. The ``join field'' is the field in each file by which the files are compared. The first field in each line is used by default. There is one line in the output for each pair of lines in file1 and file2 which have identical join fields. Each output line consists of the join field, the remaining fields from file1 and then the remaining fields from file2. The default field separators are tab and space characters. In this case, multiple tabs and spaces count as a single field separator, and leading tabs and spaces are ignored. The default output field separator is a single space character. Many of the options use file and field numbers. Both file numbers and field numbers are 1 based, i.e. the first file on the command line is file number 1 and the first field is field number 1. The following options are available: -a file_number In addition to the default output, produce a line for each unpairable line in file file_number. -e string Replace empty output fields with string. -o list The -o option specifies the fields that will be output from each file for each line with matching join fields. Each element of list has the either the form 'file_number.field', where file_number is a file number and field is a field number, or the form '0' (zero), representing the join field. The elements of list must be either comma (``,'') or whitespace separated. (The latter requires quot- ing to protect it from the shell, or, a simpler approach is to use multiple -o options.) -t char Use character char as a field delimiter for both input and output. Every occurrence of char in a line is significant. -v file_number Do not display the default output, but display a line for each unpairable line in file file_number. The options -v 1 and -v 2 may be specified at the same time. -1 field Join on the field'th field of file 1. -2 field Join on the field'th field of file 2. When the default field delimiter characters are used, the files to be joined should be ordered in the collating sequence of sort(1), using the -b option, on the fields on which they are to be joined, otherwise join may not report all field matches. When the field delimiter char- acters are specified by the -t option, the collating sequence should be the same as sort(1) without the -b option. If one of the arguments file1 or file2 is ``-'', the standard input is used. DIAGNOSTICS
The join utility exits 0 on success, and >0 if an error occurs. COMPATIBILITY
For compatibility with historic versions of join, the following options are available: -a In addition to the default output, produce a line for each unpairable line in both file 1 and file 2. -j1 field Join on the field'th field of file 1. -j2 field Join on the field'th field of file 2. -j field Join on the field'th field of both file 1 and file 2. -o list ... Historical implementations of join permitted multiple arguments to the -o option. These arguments were of the form 'file_number.field_number' as described for the current -o option. This has obvious difficulties in the presence of files named '1.2'. These options are available only so historic shellscripts don't require modification and should not be used. STANDARDS
The join command conforms to IEEE Std 1003.1-2001 (``POSIX.1''). SEE ALSO
awk(1), comm(1), paste(1), sort(1), uniq(1) BSD
April 18, 2002 BSD
All times are GMT -4. The time now is 07:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy