Sponsored Content
Top Forums UNIX for Dummies Questions & Answers any script for joining files based on simple conditions Post 302407883 by stateperl on Friday 26th of March 2010 07:12:26 PM
Old 03-26-2010
any script for joining files based on simple conditions

Condition1;
If NPID and IndID of both input1 and input2 are same take all the vaues relevant to them and print together as output

Condition2;
IDNo in output: Take the highly repeated same letter of similar NPID-IndID as *1*
Second highly repeated same letter ...................................... as* 3*
Take different letters of .......................................... as *2*

Example (Check Bold Letters): Cond1: NPID (ID1) and IndID (a1,a2,a3,a6,a8,a9 ) of input1 similar to input2
Code:
                                                 a/a  as  1
                                                 a/b  as  2
                                                 b/b  as  3

input1

Code:
IndID    ID1    ID2    ID3
a1    a/a    b/b    c/c
a2    a/a    b/b    c/c
a3    a/b    b/b    c/d
a6    a/b    b/b    c/e
a8    a/a    b/c    c/e
a9    b/b    b/d    c/e

input2

Code:
NPID    IndID    name    Dexp    DummyID    Pop
ID1    a1    ppp    10    GI1-A    CEU
ID1    a2    ppp    20    GI1-S    CEU
ID1    a3    ppp    30    GI2-A    CEU
ID1    a4    ppp    40    GI2-S    CEU
ID1    a6    ppp    79    GI9-A    CEU
ID1    a8    ppp    62    GI7-A    CEU
ID2    a9    ppp    12    GI7-S    CEU
ID2    a1    qqq    23    GI2-A    CEU
ID2    a2    qqq    26    GI3-A    CEU
ID2    a3    qqq    28    GI3-S    CEU
ID2    a4    qqq    29    GI5-A    CEU
ID2    a6    qqq    36    GI5-S    CEU
ID2    a8    qqq    46    GI6-S    CEU
ID2    a9    qqq    22    GI6-A    CEU
ID4    a1     fff    67    GI8-A    CEU



]Desired Output
Code:
NPID    name    Column1    IDs    IDNo    Dexp    DummyID    Pop
ID1    ppp    a1    a/a    1    10    GI1-A    CEU  
ID1    ppp    a2    a/a    1    20    GI1-S    CEU
ID1    ppp    a8    a/a    1    62    GI7-A    CEU
ID1    ppp    a3    a/b    2    30    GI2-A    CEU
ID1    ppp    a6    a/b    2    79    GI9-A    CEU
ID1    ppp    a9    b/b    3    12    GI7-S    CEU 
 ID2    qqq    a1    b/b    1    23    GI2-A    CEU
ID2    qqq    a2    b/b    1    26    GI3-A    CEU
ID2    qqq    a3    b/b    1    28    GI3-S    CEU
ID2    qqq    a6    b/b    1    36    GI5-S    CEU
ID2    qqq    a8    b/c    2    46    GI6-S    CEU
ID2    qqq    a9    b/d    3    22    GI6-A    CEU

Thanx in advance

Last edited by zaxxon; 03-29-2010 at 04:04 AM.. Reason: even more code tags ;)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Joining two files based on columns/fields

I've got two files, File1 and File2 File 1 has got combination of col1, col2 and col3 which comes on file2 as well, file2 does not get col4. Now based on col1, col2 and col3, I would like to get col4 from file1 and all the columns from file2 in a new file Any ideas? File1 ------ Col1 col2... (11 Replies)
Discussion started by: rudoraj
11 Replies

2. UNIX for Dummies Questions & Answers

Joining files based on multiple keys

I need a script (perl or awk..anything is fine) to join 3 files based on three key columns. The no of non-key columns can vary in each file. The columns are delimited by semicolon. For example, File1 Dim1;Dim2;Dim3;Fact1;Fact2;Fact3;Fact4;Fact5 ---- data delimited by semicolon --- ... (1 Reply)
Discussion started by: Sebben
1 Replies

3. Shell Programming and Scripting

joining files based on key column

Hi I have to join two files based on 1st column where 4th column of a2.txt=at and take 2nd column of a1.txt and 3rd column of a2.txt and check against source files ,if matches list those source file names. a1.txt a1|20090809|20090810 a2|20090907|20090908 a2.txt a1|d|file1.txt|at... (9 Replies)
Discussion started by: akil
9 Replies

4. Shell Programming and Scripting

awk merging files based on 2 complex conditions

1. if the 1st row IDs of input1 (ID1/ID2.....) is equal to any IDNames of input2 print all relevant values together as defined in the output. 2. A bit tricky part is IDno in the output. All we need to do is numbering same kind of letters as 1 (aa of ID1) and different letters as 2 (ab... (4 Replies)
Discussion started by: ruby_sgp
4 Replies

5. Shell Programming and Scripting

Joining multiple files based on one column with different and similar values (shell or perl)

Hi, I have nine files looking similar to file1 & file2 below. File1: 1 ABCA1 1 ABCC8 1 ABR:N 1 ACACB 1 ACAP2 1 ACOT1 1 ACSBG 1 ACTR1 1 ACTRT 1 ADAMT 1 AEN:N 1 AKAP1File2: 1 A4GAL 1 ACTBL 1 ACTL7 (4 Replies)
Discussion started by: seqbiologist
4 Replies

6. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file based on certain conditions

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (1 Reply)
Discussion started by: Vivekit82
1 Replies

7. Shell Programming and Scripting

Need script for making files based on some conditions.

Hi All, I have a text file (code_data.txt) with the followig data. AMAR AB123456 XYZ KIRAN CB789 ABC RAJ CS78890 XYZ KAMESH A33535335 ABC KUMAR MD678894 MAT RITESH SR3535355... (26 Replies)
Discussion started by: ROCK_PLSQL
26 Replies

8. Shell Programming and Scripting

Merge input from two files into one based on conditions

Using Linux (bash), I have two files which contain information about berries. Example: file1.txt: Blueberry blue 14 Raspberry red 12 Blackberry dark 4 file2.txt Blackberry sour 4 3 Blueberry tasty 12 78 Strawberry yummy 33 88 I want to merge these two files into one. The desired... (5 Replies)
Discussion started by: Zooma
5 Replies

9. Shell Programming and Scripting

Trouble with simple cutting, joining

Made a file called assignment1.sh and this is what's inside - #!/bin/bash $ cut -c 2 sales.txt > regionalsales.txt $ cut -c 6 sales.txt > regionalsales.txt $ cut -c 1 territory.txt > terrsummary.txt $ cut -c 2 territory.txt > terrsummary.txt $ cut -c 3 territory.txt > terrsummary.txt $ sort... (1 Reply)
Discussion started by: htzdruk
1 Replies

10. UNIX for Beginners Questions & Answers

Rename files based on simple text file

Hello! New here although not completely new to Unix. I wonder how I could rename files based on the data found in a simple textfile. It goes like this: I have 4 files 1 ldfgkkfjslkdfjsldkfjsf.wav 2 nndsdflksdjf.wav 3 sdflksjdf jjsdflsdfl.wav 4 dkadsdddd.wav Textfile.txt looks like... (14 Replies)
Discussion started by: Oortone
14 Replies
PON(1)								    Debian PPPD 							    PON(1)

NAME
pon, poff, plog - starts up, shuts down or lists the log of PPP connections SYNOPSIS
pon [ isp-name [ options ] ] poff [ -r ] [ -d ] [ -c ] [ -a ] [ -h ] [ isp-name ] plog [ arguments ] DESCRIPTION
This manual page describes the pon, plog and poff scripts, which allow users to control PPP connections. pon pon, invoked without arguments, runs the /etc/ppp/ppp_on_boot file, if it exists and is executable. Otherwise, a PPP connection will be started using configuration from /etc/ppp/peers/provider. This is the default behaviour unless an isp-name argument is given. For instance, to use ISP configuration "myisp" run: pon myisp pon will then use the options file /etc/ppp/peers/myisp. You can pass additional pppd options after the ISP name, too. pon can be used to run multiple, simultaneous PPP connections. pon takes the following command line options: -q --quick disconnect when ip-up finishes running. This function is only available to the root user. poff poff closes a PPP connection. If more than one PPP connection exists, the one named in the argument to poff will be killed, e.g. poff myprovider2 will terminate the connection to myprovider2, and leave the PPP connections to e.g. "myprovider1" or "myprovider3" up and running. poff takes the following command line options: -r causes the connection to be redialed after it is dropped. -d toggles the state of pppd's debug option. -c causes pppd(8) to renegotiate compression. -a stops all running ppp connections. If the argument isp-name is given it will be ignored. -h displays help information. -v prints the version and exits. If no argument is given, poff will stop or signal pppd if and only if there is exactly one running. If more than one connection is active, it will exit with an error code of 1. plog plog shows you the last few lines of /var/log/ppp.log. If that file doesn't exist, it shows you the last few lines of your /var/log/syslog file, but excluding the lines not generated by pppd. This script makes use of the tail(1) command, so arguments that can be passed to tail(1) can also be passed to plog. Note: the plog script can only be used by root or another system administrator in group "adm", due to security reasons. Also, to have all pppd-generated information in one logfile, that plog can show, you need the following line in your /etc/syslog.conf file: local2.* -/var/log/ppp.log FILES
/etc/ppp/options PPPd system options file. /etc/ppp/pap-secrets System PAP passwords file. /etc/ppp/chap-secrets System CHAP passwords file. /etc/ppp/peers/ Directory holding the peer options files. The default file is called provider. /etc/chatscripts/provider The chat script invoked from the default /etc/ppp/peers/provider. /var/log/ppp.log The default PPP log file. AUTHORS
The p-commands were written by Christoph Lameter <clameter@debian.org>. Updated and revised by Philip Hands <phil@hands.com>. This manual was written by Othmar Pasteka <othmar@tron.at>. Modified by Rob Levin <lilo@openprojects.net>, with some extensions taken from the old p-commands manual written by John Hasler <jhasler@debian.org>. SEE ALSO
pppd(8), chat(8), tail(1). Debian Project July 2000 PON(1)
All times are GMT -4. The time now is 04:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy