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
PSC(1) General Commands Manual PSC(1)
NAME
psc - prepare sc files
SYNOPSIS
psc [-fLkrSPv] [-s cell] [-R n] [-C n] [-n n] [-d c]
DESCRIPTION
Psc is used to prepare data for input to the spreadsheet calculator sc(1). It accepts normal ascii data on standard input. Standard out-
put is a sc file. With no options, psc starts the spreadsheet in cell A0. Strings are right justified. All data on a line is entered on
the same row; new input lines cause the output row number to increment by one. The default delimiters are tab and space. The column for-
mats are set to one larger than the number of columns required to hold the largest value in the column.
OPTIONS
-f Omit column width calculations. This option is for preparing data to be merged with an existing spreadsheet. If the option is not
specified, the column widths calculated for the data read by psc will override those already set in the existing spreadsheet.
-L Left justify strings.
-k Keep all delimiters. This option causes the output cell to change on each new delimiter encountered in the input stream. The
default action is to condense multiple delimiters to one, so that the cell only changes once per input data item.
-r Output the data by row first then column. For input consisting of a single column, this option will result in output of one row
with multiple columns instead of a single column spreadsheet.
-s cell
Start the top left corner of the spreadsheet in cell. For example, -s B33 will arrange the output data so that the spreadsheet
starts in column B, row 33.
-R n Increment by n on each new output row.
-C n Increment by n on each new output column.
-n n Output n rows before advancing to the next column. This option is used when the input is arranged in a single column and the
spreadsheet is to have multiple columns, each of which is to be length n.
-d c Use the single character c as the delimiter between input fields.
-P Plain numbers only. A field is a number only when there is no imbedded [-+eE].
-S All numbers are strings.
-v Print the version of psc
SEE ALSO
sc(1)
AUTHOR
Robert Bond
PSC 7.16 19 September 2002 PSC(1)