Sponsored Content
Full Discussion: Help in awk/bash
Top Forums UNIX for Dummies Questions & Answers Help in awk/bash Post 302749623 by bioinfo on Friday 28th of December 2012 06:09:26 PM
Old 12-28-2012
Help in awk/bash

Hi, I am also a newbie in awk and trying to find solution of my problem.

I have one reference file 1.txt with 2 columns and I want to search other 10 files (a.txt, b.txt......h.txt each with 5 columns) corresponding to the values of 2nd column from 1.txt. If the value from 2nd column from 1.txt matches with the value of 4th column of 10 files, then print the row as well as file name.
Also, in 1.txt for eg. 1st value is -191.632 but originally in a.txt it is -191.6318, so I also want to print values same upto two decimal places and rest places can be any number.

1.txt:

Code:
1.35732	-191.632
1.36229	-190.8716
1.35503	-191.3254
1.35597	-191.2652

a.txt:

Code:
271640.000	 0.49000	 -0.0000036574 -191.6318 -183.82380	
271650.000	 0.49155	 0.0000033909	 -198.30111	 -198.73140	
271660.000	 0.48775	 0.0000014657	 -191.3254 -199.84910	
271670.000	 0.48212	 -0.0000004152 -195.48446	 -193.15580

Please guide.
Thanks

Last edited by joeyg; 12-28-2012 at 09:43 PM.. Reason: Double post. Closed.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

BASH with AWK

Hello, I have a file.txt with 20000 lines and 2 columns each which consists of current_filename and new_filename . I want to create a script to find files in a directory with current_filename and move it to new folder with new_filename. Could you please help me how to do that?? ... (2 Replies)
Discussion started by: narasimhulu
2 Replies

2. Shell Programming and Scripting

Is there any better way for sorting in bash/awk

Hi, I have a file which is:- 1 6 4 8 2 3 2 1 9 3 2 1 3 3 5 6 3 1 4 9 7 8 2 3 I would like to sort from field $2 to field $6 for each of the line to:- 1 2 3 4 6 8 2 1 1 2 3 9 3 1 3 3 5 6 4 2 3 7 8 9 I came across this Arrays on example 26-6. But it is much complicated. I am... (7 Replies)
Discussion started by: ahjiefreak
7 Replies

3. Shell Programming and Scripting

awk bash help

Hi, I'm trying to read a file containing lines with spaces in them. The inputfile looks like this ------------------------------ Command1 arg1 arg2 Command2 arg5 arg6 arg7 ------------------------------- The shell code looks like this... lines=`awk '{ print }' inputfile` ... (2 Replies)
Discussion started by: a-gopal
2 Replies

4. Shell Programming and Scripting

scripting help with bash and awk

I'm trying to reformat some tide information into a useable format and failing. Input file is.... 4452 CHENNAI (MADRAS) 13°06'N, 80°18'E India East Coast 01 June 2009 UT(GMT) Data Area 3. Indian Ocean (northern part) and Red Sea to Singapore 01/06/2009 00:00 0.7 m 00:20 0.7 m 00:40... (3 Replies)
Discussion started by: garethsays
3 Replies

5. UNIX for Dummies Questions & Answers

Help with BASH/AWK queries ....

Hi Everyone, I have an input file in the following format: score.file1.txt contig00045 length=566 numreads=19 1047 0.0 contig00055 length=524 numreads=7 793 0.0 contig00052 length=535 numreads=10 607 e-176 contig00072 length=472 numreads=46 571 e-165... (8 Replies)
Discussion started by: Fahmida
8 Replies

6. Shell Programming and Scripting

AWK/Bash script

I would like to write a script to extend this command to a general case: BEGIN {s_0=0;n_0=0}{n_0++;s_0+=($51-$1)^2}END {print sqrt(s_0/n_0)} i.e. so that BEGIN {s_0=0;n_0=0}{n_0++;s_0+=($51-$1)^2}END {print sqrt(s_0/n_0)} BEGIN {s_1=0;n_1=0}{n_1++;s_1+=($51-$2)^2}END {print... (3 Replies)
Discussion started by: chrisjorg
3 Replies

7. Shell Programming and Scripting

Help in awk/bash

Hi, I have two files: atom.txt and g.txt atom.txt has multiple patterns but I am showing only two patterns each ending with ENDMDL: ATOM 1 N SER A 1 35.092 83.194 140.076 1.00 0.00 N ATOM 2 CA SER A 1 35.216 83.725 138.725 1.00 0.00 C TER ENDMDL ATOM 1 N SER A 1 35.683 81.326 139.778 1.00... (11 Replies)
Discussion started by: bioinfo
11 Replies

8. Shell Programming and Scripting

Help in awk/bash

Hi, I am also a newbie in awk and trying to find solution of my problem. I have one reference file 1.txt with 2 columns and I want to search other 10 files (a.txt, b.txt......h.txt each with 5 columns) corresponding to the values of 2nd column from 1.txt. If the value from 2nd column from 1.txt... (33 Replies)
Discussion started by: bioinfo
33 Replies

9. Shell Programming and Scripting

Returning a value from awk to bash

Hi I am a newbie starting bash and I have a simple need to return the result of an operation from awk to bash. basically I want to use awk to tell me if "#" exists in a string, and then back in bash, i want to do an IF statement on this return in order to do other things. In my bash shell I... (2 Replies)
Discussion started by: oahmad
2 Replies

10. UNIX for Dummies Questions & Answers

New problem with awk using bash

Hi! I have a new problem with awk, this time I think is because I'm using it in bash and I don't know how to put the valor of the variable in awk. Here is the code: #!/bin/bash for i in 1 2 3 4 5 do a=$i b=$ awk '$1>=a&&$1<=b {print $1,$2,$3}'>asdf test... (3 Replies)
Discussion started by: florpi
3 Replies
X2SYS_SOLVE(1gmt)					       Generic Mapping Tools						 X2SYS_SOLVE(1gmt)

NAME
x2sys_solve - Determine systematic corrections from crossovers SYNOPSIS
x2sys_solve -Ccolumn -TTAG -Emode [ COE_list.d ] [ -V ] [ -W ] [ -Z ] [ -bi[s|S|d|D[ncol]|c[var1/...]] ] DESCRIPTION
x2sys_solve will use the supplied crossover information to solve for systematic corrections that can then be applied per track to improve data quality. Several systematic corrections can be solved for using a least-squares approach. Note: Only one data column can be processed at the time. -T Specify the x2sys TAG which tracks the attributes of this data type. -C Specify which data column you want to process. Needed for proper formatting of the output correction table and must match the same option used in x2sys_list when preparing the input data. -E The correction type you wish to model. Choose among the following functions f(p), where p are the m parameters per track that we will fit simultaneously using a least squares approach: c will fit f(p) = a (a constant offset); records must contain cruise ID1, ID2, COE. d will fit f(p) = a + b * d (linear drift; d is distance; records must contain cruise ID1, ID2, d1, d2, COE. g will fit f(p) = a + b sin(y)^2 (1980-1930 gravity correction); records must contain cruise ID1, ID2, latitude y, COE. h will fit f(p) = a + b cos(H) + c cos(2H) + d sin(H) + e sin(2H) (magnetic heading correction); records must contain cruise ID1, ID2, heading H, COE. s will fit f(p) = a * z (a unit scale correction); records must contain cruise ID1, ID2, z1, z2. t will fit f(p) = a + b * (t - t0) (linear drift; t0 is the start time of the track); records must contain cruise ID1, ID2, t1-t0, t2-t0, COE. OPTIONS
No space between the option flag and the associated arguments. COE_list.d Name of file with the required crossover columns as produced by x2sys_list. NOTE: If -bi is used then the first two columns are expected to hold the integer track IDs; otherwise we expect those columns to hold the text string names of the two tracks. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. -W Means that each input records has an extra column with the composite weight for each crossover record. These are used to obtain a weighted least squares solution [no weights]. -Z For -Ed and -Et, determine the earliest time or shortest distance for each track, then use these values as the local origin for time duration or distance calculations. The local origin is then included in the correction table [Default uses 0]. -bi Selects binary input. Append s for single precision [Default is d (double)]. Uppercase S or D will force byte-swapping. Option- ally, append ncol, the number of columns in your binary input file if it exceeds the columns needed by the program. Or append c if the input file is netCDF. Optionally, append var1/var2/... to specify the variables to be read. EXAMPLES
To fit a simple bias offset to faa for all tracks under the MGD77 tag, try x2sys_list COE_data.txt -V -TMGD77 -Cfaa -Fnc > faa_coe.txt x2sys_solve faa_coe.txt -V -TMGD77 -Cfaa -Ec > coe_table.txt To fit a faa linear drift with time instead, try x2sys_list COE_data.txt -V -TMGD77 -Cfaa -FnTc > faa_coe.txt x2sys_solve faa_coe.txt -V -TMGD77 -Cfaa -Et > coe_table.txt To estimate heading corrections based on magnetic crossovers associated with the tag MGD77 from the file COE_data.txt, try x2sys_list COE_data.txt -V -TMGD77 -Cmag -Fnhc > mag_coe.txt x2sys_solve mag_coe.txt -V -TMGD77 -Cmag -Eh > coe_table.txt To estimate unit scale corrections based on bathymetry crossovers, try x2sys_list COE_data.txt -V -TMGD77 -Cdepth -Fnz > depth_coe.txt x2sys_solve depth_coe.txt -V -TMGD77 -Cdepth -Es > coe_table.txt SEE ALSO
x2sys_binlist(1), x2sys_cross(1), x2sys_datalist(1), x2sys_get(1), x2sys_init(1), x2sys_list(1), x2sys_put(1), x2sys_report(1) GMT 4.5.7 15 Jul 2011 X2SYS_SOLVE(1gmt)
All times are GMT -4. The time now is 01:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy