I am facing problem to get right output through awk program
I have file in which “B” value is appearing multiple time and I need to capture all these values.
My script is
Code:
BEGIN { FS=" " }
{
if ( substr($1,1,5) == "START" )
{
i = i+1;
SFILENAME[i] = FILENAME
}
if ( $1 == "input" )
INPUT[i] = $2
if ( $1 == "output" )
OUTPUT[i] = $2
if ( $1 == "B" && k < i )
{
k = k+1;
B[k] = $2
}
if ( $2 == "input_type" )
INPUT_TYPE[i] = $3
if ( $2 == "output_type" )
OUTPUT_TYPE[i] = $3
if ( $1 == "B" )
B_2[i] = $2
}
END{ for (j=1 ; j <=i ; j++ )
printf "%s,%s,%s,%s,%s,%s,\n",SFILENAME[j],INPUT[j],OUTPUT[j],B[kh],INPUT_TYPE[j],OUTPUT_TYPE[j],B_2[j]
}
And sample file is
Code:
START
input AAAA
output AAAA.output
B 567
B extra
F input_type xxv
F output_type xxvoo
B 333
.
.
F input_type xxd
B arv
.
START
input BBBB
output BBBB.output
B 666
F input_type xxv
F output_type xxvoo
.
.
F input_type xxd
B arv
.
START
input BBBB
output BBBB.output
B 666
F input_type xxv
F output_type xxvoo
.
.
F input_type xxd
B arv
.
.
START
input NNNN
output NNNN.output
B 54
B extra
F input_type xxv
F output_type xxvoo
B 656
.
.
F input_type xxd
file.txt,AAAA,AAAA.output, 567, extra,xxd,xxvoo, arv
file.txt,BBBB,BBBB.output, 666,xxd,xxvoo, arv
file.txt,BBBB,BBBB.output, 54,xxd,xxvoo, 656
file.txt,NNNN,NNNN.output,,xxd,xxvoo,
Edit by pludi: please use code tags, and please don't change the font and size for each line individually. It's possible to do this for the whole text, which improves rendering.
Last edited by pludi; 04-07-2010 at 04:51 AM..
Reason: code tags, please..
hi i am trying to perform some calculations with awk and arrays. i have this so far:
awk 'NR==FNR{ for(i=1; i<=NF; i++) {array+=$i} tot++;next}
{for(i=1; i<=NF; i++) {avg=array/tot} {diff=(array - avg)}} {for(i=1; i<=NF; i++) {printf("%5.8f\n",diff)}}' "$count".txt "$count".ttt >... (4 Replies)
I'm at wits end with this issue and my troubleshooting leads me to believe it is a problem with the file formatting of the array referenced by my script:
awk -F, '{if (NR==FNR) {a=$4","$3","$2}\
else {print a "," $0}}' WBTSassignments1.txt RNCalarms.tmp
On the WBTSassignments1.txt file... (2 Replies)
Hi all,
i have a data array as follows.
array=ertfgj2345
array=456ttygkd
.
.
.
array=errdjt3235
so number or elements in the array can varies depending on how big the data input is.
now i have a variable, and it is $1 (there are $2, $3 and so on, i am only interested in $1).
... (9 Replies)
Hi,
I rather have a very complicated awk problem here, at least to me. I have two files.
File 1:
607 687 174 0 0 chr1 3000001 3000156 -194195276 - L1_Mur2 LINE L1 -4310 1567 1413 1
607 917 214 114 45 chr1 3000237 ... (19 Replies)
Hi,
Im trying to count bats flying through an infrared beam array. One of the experts here helped me a few months ago but now I am having a problem that is stumping me.
here is the original code that works (with two differnt patterns in array):
# this has been changed to operate under the... (15 Replies)
I am trying to map values in the input file, where 2nd column depends on the specific value in the 1st column. When 1st column is A place 1 into 2nd column, when it is B, place 2, when C place 3, otherwise no change.
My input:
U |100|MAIN ST |CLMN1|1
A |200|GREEN LN |CLMN2|2
1 |12... (4 Replies)
Hello experts,
I'm stuck with this script for three days now. Here's what i need.
I need to split a large delimited (,) file into 2 files based on the value present in the last field.
Samp: Something.csv
bca,adc,asdf,123,12C
bca,adc,asdf,123,13C
def,adc,asdf,123,12A
I need this split... (6 Replies)
Hi, I have a problem with awk array when iam trying to use awk in solaris box as below..Iam unable to figure out the problem..
Need your help. is there any alternative to make it in arrays from variable values
nawk 'BEGIN {SUBSEP=" ";
split("101880|110045 101887|110045 101896|110045... (9 Replies)
Hello All,
Can you please help me with the below.
#!/bin/bash
ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5 EXTRACT_DT:30-SEP-12 VER_NUM:1"
ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5... (14 Replies)
I am trying to reformat the table by filling any missing rows. The final table will have consecutive IDs in the first column. My problem is the index of the associate array in the awk script.
infile:
S01 36407 53706 88540
S02 69343 87098 87316
S03 50133 59721 107923... (4 Replies)
Discussion started by: yifangt
4 Replies
LEARN ABOUT OPENDARWIN
start_transaction
START TRANSACTION(7) SQL Commands START TRANSACTION(7)NAME
START TRANSACTION - start a transaction block
SYNOPSIS
START TRANSACTION [ transaction_mode [, ...] ]
where transaction_mode is one of:
ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }
READ WRITE | READ ONLY
DESCRIPTION
This command begins a new transaction block. If the isolation level or read/write mode is specified, the new transaction has those charac-
teristics, as if SET TRANSACTION [set_transaction(7)] was executed. This is the same as the BEGIN [begin(7)] command.
PARAMETERS
Refer to SET TRANSACTION [set_transaction(7)] for information on the meaning of the parameters to this statement.
COMPATIBILITY
In the standard, it is not necessary to issue START TRANSACTION to start a transaction block: any SQL command implicitly begins a block.
PostgreSQL's behavior can be seen as implicitly issuing a COMMIT after each command that does not follow START TRANSACTION (or BEGIN), and
it is therefore often called ``autocommit''. Other relational database systems might offer an autocommit feature as a convenience.
The SQL standard requires commas between successive transaction_modes, but for historical reasons PostgreSQL allows the commas to be omit-
ted.
See also the compatibility section of SET TRANSACTION [set_transaction(7)].
SEE ALSO
BEGIN [begin(7)], COMMIT [commit(7)], ROLLBACK [rollback(7)], SAVEPOINT [savepoint(7)], SET TRANSACTION [set_transaction(7)]
SQL - Language Statements 2010-05-14 START TRANSACTION(7)