09-03-2007
using awk to search and print output
suppose i have one file
file A
18
24
30
35
38
45
55
Another file file B
08_46 A 16 V -0.36 0.23 E : 1.41
08_46 A 17 D -1.04 0.22 E : 0.84
08_46 A 18 Q -0.49 0.12 E : 0.06
08_46 A 19 G 0.50 0.14 E : 0.05
08_46 A 20 V 0.10 0.22 E : 1.26
08_46 A 21 L 0.23 0.22 E : 1.14
08_46 A 22 N -0.86 0.15 E : 0.26
08_46 A 23 N 0.25 0.10 E : 0.18
08_46 A 24 G -0.83 0.20 E : 1.17
08_46 A 25 C 0.39 0.10 E : 0.01
08_46 A 26 F 0.11 0.24 E : 0.54
08_46 A 27 V 0.13 0.15 E : 0.15
08_46 A 28 D 0.23 0.15 B : 0.14
08_46 A 29 A 0.84 0.09 B : 0.54
08_46 A 30 L 0.17 0.16 E : 0.07
08_46 A 31 N 0.36 0.16 E : 0.31
08_46 A 32 V -0.60 0.15 B : 0.08
08_46 A 33 V 0.95 0.07 B : 0.82
08_46 A 34 P 0.59 0.12 E : 0.12
08_46 A 35 H 0.26 0.17 E : 0.15
08_46 A 36 V 0.96 0.09 B : 0.55
08_46 A 37 F 1.01 0.20 E : 0.40
08_46 A 38 L -0.20 0.18 E : 0.50
08_46 A 39 L -0.07 0.18 E : 0.07
08_46 A 40 F 1.05 0.10 B : 0.42
08_46 A 41 I 0.02 0.20 E : 0.37
08_46 A 42 T 0.23 0.16 E : 0.44
08_46 A 43 F 0.12 0.08 B : 0.41
08_46 A 44 P 0.20 0.10 B : 0.56
08_46 A 45 I 0.04 0.23 E : 1.17
08_46 A 46 L -0.21 0.17 E : 0.05
08_46 A 47 F 0.28 0.11 B : 0.30
08_46 A 48 I 0.49 0.23 E : 0.43
08_46 A 49 G 0.15 0.12 B : 0.12
08_46 A 50 W 0.40 0.17 E : 0.09
08_46 A 51 G 0.27 0.14 B : 0.09
08_46 A 52 S 0.17 0.02 B : 1.07
08_46 A 53 Q 0.27 0.08 B : 0.37
08_46 A 54 S 0.01 0.03 B : 0.76
08_46 A 55 S 0.04 0.11 B : 0.45
so we have file B where third column are in common with file A
so the output shud be like
08_46 A 18 Q -0.49 0.12 E : 0.06
08_46 A 30 L 0.17 0.16 E : 0.07
08_46 A 35 H 0.26 0.17 E : 0.15
08_46 A 38 L -0.20 0.18 E : 0.50
08_46 A 45 I 0.04 0.23 E : 1.17
08_46 A 55 S 0.04 0.11 B : 0.45
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Suppose u have a file like
1 30
ABCSAAHSNJQJALBALMKAANKAMLAMALK
4562676268836826826868268468368282972982
2863923792102370179372012792701739729291
31 60... (8 Replies)
Discussion started by: cdfd123
8 Replies
2. Shell Programming and Scripting
Hello.
I've been banging my head against walls trying to search a comma delimited file, using awk. I'm trying to search a "column" for a specific parameter, if it matches, then I'd like to print the whole line.
I've read in multiple texts:
awk -F, '{ if ($4 == "string") print $0 }'... (2 Replies)
Discussion started by: Matthias03
2 Replies
3. Shell Programming and Scripting
I have multiple config files where I need to pull the ip address from loopback3. The format is the same in every file, the ip is the second line after interface loopback3.
interface loopback2 loopback
description router ID
ip address 192.168.1.1
interface loopback3 loopback
description... (3 Replies)
Discussion started by: numele
3 Replies
4. Shell Programming and Scripting
I have a script where I need to use awk, go through some output, which is stored in a variable, and find a string Xms and Xmx and print the results, including the rest of that string.
Example of string:
... (3 Replies)
Discussion started by: cbo0485
3 Replies
5. Shell Programming and Scripting
You have two files to compare by searching keyword from one file into another file
File A
23 >pp_ANSWER
24 >aa hello
25 >jau head wear
66 >jss oops
872 >aqq olps ploww oww sss
722 >GG_KILLER
..... large files
File B
Beta done
KILLER
John Mayor
calix meyers
... (5 Replies)
Discussion started by: cdfd123
5 Replies
6. Shell Programming and Scripting
I have a file which is
DFDG
START
DSFDS
DSDS
XXX
END (VIO)
AADD
START
SDSD
FGFG
END
and I have to print the lines between START and END (VIO). In the files there are multiple places where START would be followed by END with few lines in between but I need to print only if START is... (18 Replies)
Discussion started by: pgbuddy
18 Replies
7. Shell Programming and Scripting
Hi All,
I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file.
Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies
8. Shell Programming and Scripting
Input:
9999~cbc~100~209~ozzxczcz~10001001001~100~abc10
123~a~sdklfjl~sldoi~~~ksjdfnkjsdf~123456
125~g~sdklfjl~slsdfsdfsdfsdfdoi~~~~~~~~ksjdfnkjsdf~345
127~wera~sdklfjl~sldoi~~~ksjdfnkjsdf~123
128~awer~swerwerdklfjl~sldoi~~~ksjdfnkjsf~1da2345... (7 Replies)
Discussion started by: onesuri
7 Replies
9. Shell Programming and Scripting
GOODNUMBERS="1 2 3 4 5 6 3 3 34 34 5 66 12"
BADNUMBERS="7 3 12 5 66"
for eachnum in `echo ${GOODNUMBERS}`
do
echo ${BADNUMBERS} | gawk -v threshold=${eachnum} '$1 != threshold'
done
what im trying to do with the above is, i want to print numbers that are in the GOODNUMBERS... (10 Replies)
Discussion started by: SkySmart
10 Replies
10. Shell Programming and Scripting
Hello.
I have been looking high and low for the solution for this. I seems there should be a simple answer, but alas.
I have a big xml file, and I need to extract certain information from specific items. The information I need can be found between a specific set of tags. let's call them... (2 Replies)
Discussion started by: Tobias-Reiper
2 Replies
LEARN ABOUT PHP
db2_field_width
DB2_FIELD_WIDTH(3) 1 DB2_FIELD_WIDTH(3)
db2_field_width - Returns the width of the current value of the indicated column in a result set
SYNOPSIS
int db2_field_width (resource $stmt, mixed $column)
DESCRIPTION
Returns the width of the current value of the indicated column in a result set. This is the maximum width of the column for a fixed-length
data type, or the actual width of the column for a variable-length data type.
PARAMETERS
o $stmt
- Specifies a statement resource containing a result set.
o $column
- Specifies the column in the result set. This can either be an integer representing the 0-indexed position of the column, or a
string containing the name of the column.
RETURN VALUES
Returns an integer containing the width of the specified character or binary data type column in a result set. If the specified column
does not exist in the result set, db2_field_width(3) returns FALSE.
SEE ALSO
db2_field_display_size(3), db2_field_name(3), db2_field_num(3), db2_field_precision(3), db2_field_scale(3), db2_field_type(3).
PHP Documentation Group DB2_FIELD_WIDTH(3)