Sponsored Content
Top Forums Shell Programming and Scripting Awk Array doesnt match for substring Post 302322019 by pinnacle on Tuesday 2nd of June 2009 02:42:25 PM
Old 06-02-2009
Awk Array doesnt match for substring

Awk Array doesnt match for substring

Quote:
file1
cluster1,565,345
cluster2,345,345
cluster3,345,564
cluster4,345,5643
xyz.cluster1,345,64
xyz.cluster2,345,434

Quote:
file2
458,xyz.cluster1
123,cluster1
456,cluster2
767,cluster3int
Code:
nawk -F"," 'FNR==NR{a[$1]=$2 OFS $3;next} a[$2]{print $1,$2,a[$2]}' OFS="," file1 file2

I want cluster3 in file1 to match with cluster3int in file2
output getting:
Quote:
458,xyz.cluster1,345,64
123,cluster1,565,345
456,cluster2,345,345
Output required:
Quote:
458,xyz.cluster1,345,64
123,cluster1,565,345
456,cluster2,345,345
767,cluster3int,345,564
Help is appreciated
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

compare two files if doesnt match then display error message

hi , i have one file ,i need to search particular word from this file and if content is matched then echo MATCHED else NOT MATCHED file contains : mr x planned to score 75% in exam but end up with 74%. word to be searched id 75% please help me out . waiting for reply thanks in advance (2 Replies)
Discussion started by: atl@mav
2 Replies

2. Shell Programming and Scripting

awk should output if one input file doesnt have matching key

nawk -F, 'FNR==NR{a= $3 ;next} $2 in a{print $1, 'Person',$2, a}' OFS=, filea fileb Input filea Input fileb output i am getting : (2 Replies)
Discussion started by: pinnacle
2 Replies

3. Shell Programming and Scripting

Substring match

Hi, I want to find a file / directory with the name xxxxCELLxxx in the given path. The CELL is can be either in a UPPER or lower case. Thanks (4 Replies)
Discussion started by: youknowme
4 Replies

4. Shell Programming and Scripting

Match elements in an AWK multi-dimensional array

Hello, I have two files in the following format; file1: A B C D E F G H I J K L file2: 1 2 3 4 5 6 7 8 9 10 11 12 I have read them both in to multi-dimensional arrays. I need a file that has column 2 of the first file printed out for each column 3 of the second file ie... ... (3 Replies)
Discussion started by: cold_Que
3 Replies

5. Shell Programming and Scripting

PERL : Sort substring occurrences in array of strings

Hi, My developer is on vacation and I am not sure if there is something which is easier for this. I have an array of strings. Each string in the array has "%" characters in it. I have to get the string(s) which have the least number of "%" in them. I know how I can get occurrences : ... (7 Replies)
Discussion started by: sinpeak
7 Replies

6. Shell Programming and Scripting

array and awk match function in SunOS 5.10

Hi Experts, Need help in writing a shell script in SunOS 5.10. I want to use array but it is not running in SunOs where as it is running in unix. pls help Want to print the alue store in array as below but it is giving error. p=1 p=6 p=15 p=20 for i in 1 2 3 4 do echo ${p} done ... (2 Replies)
Discussion started by: forroughuse
2 Replies

7. UNIX for Dummies Questions & Answers

Deleting files based on Substring match

In folder there are files (eg ABS_18APR2012_XYZ.csv DSE_17APR2012_ABE.csv) . My requirement is to delete all the files except today's timestamp I tried doing this to list all the files not having today's date timestamp #!/bin/ksh DATE=`date +"%d%h%Y"` DIR=/data/rfs/... (9 Replies)
Discussion started by: manushi88
9 Replies

8. UNIX for Beginners Questions & Answers

Count the number of files to delete doesnt match

Good evening, need your help please Need to delete certain files before octobre 1 2016, so need to know how many files im going to delete, for instance ls -lrt file_20160*.lis!wc -l but using grep -c to another file called bplist which contains the list of all files backed up doesn match... (7 Replies)
Discussion started by: alexcol
7 Replies

9. Shell Programming and Scripting

Parsing the longest match substring

Hello gurus, I have a database of possible primary signal strings pp22 pt22dx pp22dx jty2234 Also I have a list of scrambled signals which has a shorter string and a longer string separated by // (double slash ). Always the shorter string of a scrambled signal will have the primary... (6 Replies)
Discussion started by: senhia83
6 Replies

10. Shell Programming and Scripting

Match substring from a column of the second file

I want to merge the lines by matching substring of the first file with first column of the second file. file1: S00739A_ACAGTG_L001_R1.fq.gz S00739A_ACAGTG_L001_R2.fq.gz S00739B_GCCAAT_L001_R1.fq.gz S00739B_GCCAAT_L001_R2.fq.gz S00739D_GTGAAA_L001_R1.fq.gz S00739D_GTGAAA_L001_R2.fq.gz... (14 Replies)
Discussion started by: yifangt
14 Replies
funcen(1)							SAORD Documentation							 funcen(1)

NAME
funcen - find centroid (for binary tables) SYNOPSIS
funcen [-i] [-n iter] [-t tol] [-v lev] <iname> <region> OPTIONS
-i # use image filtering (default: event filtering) -n iter # max number of iterations (default: 0) -t tol # pixel tolerance distance (default: 1.0) -v [0,1,2,3] # output verbosity level (default: 0) DESCRIPTION
funcen iteratively calculates the centroid position within one or more regions of a Funtools table (FITS binary table or raw event file). Starting with an input table, an initial region specification, and an iteration count, the program calculates the average x and y position within the region and then uses this new position as the region center for the next iteration. Iteration terminates when the maximum number of iterations is reached or when the input tolerance distance is met for that region. A count of events in the final region is then output, along with the pixel position value (and, where available, WCS position). The first argument to the program specifies the Funtools table file to process. Since the file must be read repeatedly, a value of "stdin" is not permitted when the number of iterations is non-zero. Use Funtools Bracket Notation to specify FITS extensions and filters. The second required argument is the initial region descriptor. Multiple regions are permitted. However, compound regions (accelerators, variable argument regions and regions connected via boolean algebra) are not permitted. Points and polygons also are illegal. These restrictions might be lifted in a future version, if warranted. The -n (iteration number) switch specifies the maximum number of iterations to perform. The default is 0, which means that the program will simply count and display the number of events in the initial region(s). Note that when iterations is 0, the data can be input via stdin. The -t (tolerance) switch specifies a floating point tolerance value. If the distance between the current centroid position value and the last position values is less than this value, iteration terminates. The default value is 1 pixel. The -v (verbosity) switch specifies the verbosity level of the output. The default is 0, which results in a single line of output for each input region consisting of the following values: counts x y [ra dec coordsys] The last 3 WCS values are output if WCS information is available in the data file header. Thus, for example: [sh] funcen -n 0 snr.ev "cir 505 508 5" 915 505.00 508.00 345.284038 58.870920 j2000 [sh] funcen -n 3 snr.ev "cir 505 508 5" 1120 504.43 509.65 345.286480 58.874587 j2000 The first example simply counts the number of events in the initial region. The second example iterates the centroid calculation three times to determine a final "best" position. Higher levels of verbosity obviously imply more verbose output. At level 1, the output essentially contains the same information as level 0, but with keyword formatting: [sh] funcen -v 1 -n 3 snr.ev "cir 505 508 5" event_file: snr.ev initial_region: cir 505 508 5 tolerance: 1.0000 iterations: 1 events: 1120 x,y(physical): 504.43 509.65 ra,dec(j2000): 345.286480 58.874587 final_region1: cir 504.43 509.65 5 Level 2 outputs results from intermediate calculations as well. Ordinarily, region filtering is performed using analytic (event) filtering, i.e. that same style of filtering as is performed by fundisp and funtable. Use the -i switch to specify image filtering, i.e. the same style filtering as is performed by funcnts. Thus, you can per- form a quick calculation of counts in regions, using either the analytic or image filtering method, by specifying the -n 0 and optional -i switches. These two method often give different results because of how boundary events are processed: [sh] funcen snr.ev "cir 505 508 5" 915 505.00 508.00 345.284038 58.870920 j2000 [sh] funcen -i snr.ev "cir 505 508 5" 798 505.00 508.00 345.284038 58.870920 j2000 See Region Boundaries for more information about how boundaries are calculated using these two methods. SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funcen(1)
All times are GMT -4. The time now is 04:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy