Tag Archives: FNR

awk & zcat not working together

By siramitsharma

I have a tar file which i want to read and check some specific fields basis on which i want to get output.
Code

Code:


zcat samplefile.tar.gz | awk 'FNR==1 {++counter}
counter ==1 {BB[$1]=1;next}
substr($0,26,2)!="02") {next}
(substr($0,28,12) ~ "^[A-Z,a-z]") {next}
(substr($0,184,3) in BB) {next}
1
' bb.txt


bb.txt
1234
5678

samplefile.tar.gz:
000000000000003255816850602YD-MTSBAL 519131689141165735 1120120901213655201209032136550000000001132005060000000001 405891364839056 2377 00000000000004294967040405899136999995

000000000000005255817273002919875129904 119132018104840216 1120120901213658201209032136580000000000033000160000000000405891742168097 161A 12283000032014294967040405899136999995

Need output as
000000000000005255817273002919875129904 119132018104840216 1120120901213658201209032136580000000000033000160000000000405891742168097 161A 12283000032014294967040405899136999995

From: http://www.unix.com/shell-programming-scripting/221029-awk-zcat-not-working-together.html

Navidea's Presentation of Top-Line Interim Analysis of Lymphoseek® Head and Neck Phase 3 Trial Selec

By Business Wirevia The Motley Fool

Filed under:

Navidea’s Presentation of Top-Line Interim Analysis of Lymphoseek ® Head and Neck Phase 3 Trial Selected for Investigator Award

– Data presented at the 2 nd International Symposium on Thoracic and Upper Aerodigestive Malignancies –

DUBLIN, Ohio–(BUSINESS WIRE)– Navidea Biopharmaceuticals, Inc. (NYSE MKT: NAVB), a biopharmaceutical company focused on precision diagnostic radiopharmaceuticals, today announced that a presentation of results from its Phase 3 clinical trial of Lymphoseek® (technetium 99m tilmanocept) Injection in patients with head and neck squamous cell carcinoma received the 1st Investigator Award at the 2nd InternationaI Symposium on Thoracic and Upper Aerodigestive Malignancies. The symposium was held April 4-6, 2013 in Athens, Greece. The presentation of recently announced top-line interim results for the Phase 3 Lymphoseek study and a summary of results from three of the study’s highest-accruing clinical trial sites were made by Dr. Michael Blue, MD, Senior Medical Director of Navidea Biopharmaceuticals, one of the authors.

Poster Title:

The CD206-Targeted, Molecular Sentinel Node Mapping Agent Tc99m-Tilmanocept Accurately Stages Head/Neck Squamous Cell Carcinomas (HNSCC): Prospective Interim Analysis Results From a Phase-3 Multi-Institutional Study.

Authors:

Frank Civantos, MD, FACS, University of Miami; Stephen Y. Lai, MD PhD, FACS, The M.D. Anderson Cancer Center; Amit Agrawal, MD, FACS, Ohio State University Wexner Medical Center; Douglas B. Chepeha, MD, MSP, University of Michigan; Kevin T. Brumund, MD, FACS, UCSD Medical Center; and Frederick O. Cope, PhD, Michael Blue, Wendy Metz, PhD, Bonnie C. Abbruzzese, MS, CCRA, Navidea.

The results presented by Dr. Blue et al included a summary of the pre-planned statistical interim analysis of the primary endpoint on the entire study, as recently announced by Navidea. The primary endpoint for the NEO3-06 trial was based on the number of subjects with pathology-positive lymph nodes (that is, lymph nodes found to harbor cancer) following a multiple level lymph node dissection and required a minimum of 38 subjects whose lymph nodes contained pathology-confirmed disease. Thirty-nine subjects were determined to have pathology-positive lymph nodes and were included in the interim analysis. Results from these 39 subjects demonstrated that Lymphoseek accurately identified 38, for an overall False Negative Rate (FNR) of 2.56%.

In addition, the authors reviewed a preliminary evaluation of the NEO3-06 trial data from three of the highest-accruing clinical sites. A total of 50 subjects were evaluated from these sites; 21 had pathology-positive lymph nodes. Results indicated that Lymphoseek identified these pathology-positive lymph nodes in 21 out of 21 subjects for an FNR of 0%. The total

From: http://www.dailyfinance.com/2013/04/11/navideas-presentation-of-top-line-interim-analysis/

How to deal with multidimensional array in awk?

By Akshay Hegde

Hi all!

I would like to know how to print

Code:

$0


when using multidimensional array like below

time being I am using for loop to print columns like this

Code:

awk 'FNR==1{i++}
{for(k=1;k<=NF;k++)A[i,FNR,k]=$k}
END{for(j=1;j<=25;j++)
print A[2,1,1],A[2,1,2],A[2,j,3],A[2,j,4],A[2,j,1],A[2,j,2],A[2,j,3],A[2,j,4],A[1,j,1],A[1,j,1],A[1,j,2],A[1,j,3],A[1,j,4],A[1,j,1]}' file1 file2


so here my problem is I have more than 15 column that means whether I have to type like below till 15th column

Code:

A[2,j,1],A[2,j,2],.....A[2,j,15]


or any other solution is available ?

thanks in advance

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

How to solve awk: line 1: runaway string constant error?

By Akshay Hegde

Hi All !

I am just trying to print bash variable in awk statement as string
here is my script

Code:

n=1
for file in `ls *.tk |sort -t"-" -k2n,2`; do
ak=`(awk 'FNR=='$n'{print $0}' res.dat)`

awk '{print "'$ak'",$0}' OFS="t" $file
n=$((n+1))
unset ak
done


I am getting following error

Code:

awk: line 1: runaway string constant


is there any solution to read reference file first line print with 1st file(in loop) $0, then read 2nd line from reference file print with 2nd file in loop

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

How to take awk result out (piping to other program)?

By Akshay Hegde

Hi! all here is my code
which is working fine no errors but I want to know how to take result and input to other program

Code:

awk 'FNR==1{i++}{LC[i]=NR}
{for(k=1; k<=NF; k++) A[i,FNR,k]=$k}
END{for (i=1;i<=LC[1];i++)
{
for(j=1;j<=LC[2];j++)
if(A[2,j,8]=='$UID' && A[2,j,4]>='$MX'+A[1,i,3] && A[2,j,4]<='$MIN'+A[1,i,4] &&
A[2,j,4]>='$MN'+A[1,i,1] && A[2,j,5]<='$MX'+A[1,i,2])
print A[2,j,6],A[2,j,7]
}}' OFS="t" STD_FIILE FILE2 | program(print) command -XA[2,j,5] -Y[2,j,5] -------------> if statement is true


if if statement is awk program in false

then

Code:

OFS="t" STD_FIILE FILE2 | program(mask) command -XA[2,j,5] -Y[2,j,5] ------------->


please help me

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

awk Merging multiple files with symbol representing new file

By Akshay Hegde

I just tried following

Code:

ls *.dat|sort -t"_" -k2n,2|while read f1 && read f2; do
awk '{print}' $f1
awk FNR==1'{print $1,$2,$3,$4,$5,"*","*","*" }' OFS="t" $f2
awk '{print}' $f2
done


got following result

Code:

18-Dec-1983 11:45:00 AM 18.692 84.672 0 25.4 24
18-Dec-1983 11:45:00 AM 18.692 84.672 5 25.5 24
18-Dec-1983 11:45:00 AM 18.692 84.672 10 26 24
18-Dec-1983 03:22:00 PM 18.327 84.29 * * *
18-Dec-1983 03:22:00 PM 18.327 84.29 0 24.5 24
18-Dec-1983 03:22:00 PM 18.327 84.29 5 24.6 24
18-Dec-1983 03:22:00 PM 18.327 84.29 10 24.8 24
18-Dec-1983 03:22:00 PM 18.327 84.29 40 27.1 24
18-Dec-1983 03:22:00 PM 18.327 84.29 45 27 24
18-Dec-1983 06:45:00 PM 18.025 83.962 0 26.4 23 -- > before this line * symbol suppose to come
18-Dec-1983 06:45:00 PM 18.025 83.962 5 26.5 23
18-Dec-1983 06:45:00 PM 18.025 83.962 10 26.5 23
18-Dec-1983 06:45:00 PM 18.025 83.962 15 26.8 23


Can anyone tell me why it’s not coming and what’s solution ?

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Why result is wrong here ? whether break statement is wrong ?

By Akshay Hegde

Hi ! all I am just trying to check range in my datafile

pls tell me why its resulting wrong

Code:

admin@IEEE:~/Desktop$ cat test.txt
0 28.4
5 28.4
10 28.4
15 28.5
20 28.5
25 28.6
30 28.6
35 28.7
40 28.7
45 28.7
50 28.8
55 28.8
60 28.8
65 28.1
70 26.5


This I tried

Code:

awk 'FNR==1{i++}{LC[i]=NR}
{for(k=1; k<=NF; k++)A[i,FNR,k]=$k} #ARRAY
END{
j=1;
while(j<=LC[1]) # IF J<=Line Count do following
{
x=A[1,j,2]-A[1,1,2] # Column2 records - Column2 1st Record
if(x>0.1) # IF above statement result is greater than 0.1
break; # Break loop, save index in variable,save column2 record
p1=j;
h1=A[1,j,1]; # IF not increment j
j++;
}

l=1;
while(l<=LC[1]) # IF l<=Line Count do following
{
y=A[1,l,2]-A[1,1,2] # Column2 records - Column2 1st Record
if(y<-0.1) # IF above statement result is less than 0.1
break; # Break loop, save index in variable,save column2 record
p2=l;
h2=A[1,l,1]; # IF not increment l
l++;
}
{
for(m=p1;m<=p2;m++) # Use Index stored in p1 and p2 of 1st and 2nd while loop print records in that range
{print A[1,m,1],A[1,m,2],h1,h2,p1,p2,FILENAME,x,y,A[1,1,2],A[1,1,1]}
}
}' OFS="t" test.txt


Resulting

Code:

admin@IEEE:~/Desktop$ sh awk.sh
10 28.4 10 60 3 13 test.txt 0.1 -0.3 28.4 0 --This is wrong
15 28.5 10 ...read more
Source: FULL ARTICLE at The UNIX and Linux Forums

awk to find lines containing word that occur multiple times

By SkySmart

i have a script that scans a log file every 10 minutes. this script remembers the last line of the log and then uses it to continue monitoring the log when it runs again 10 minutes later.

the script searches the log for a string called MaxClients.

now, how can i make it so that when the script runs, it’ll let me know when it finds not just 1 but 3 lines containing MaxClients?

Code:

awk 'FNR=>'5034' logfile | egrep MaxClients


sounds simple enough. but there’s a catch. lets say the log file can contains:

Code:

Warning MaxClient is having issues - please
MaxClients java error...yams potato turkey
MaxClients error Fatal exception known known
MaxClients error Fatal exception known known
Could not complete. Error found. MaxClient initiated
MaxClients error Fatal exception known known
Could not complete. Error found. MaxClient initiated


in the above example, the script should only output the lines:

Code:

MaxClients error Fatal exception known known
MaxClients error Fatal exception known known
MaxClients error Fatal exception known known


This is because, this is the line that occurred at least 3 times when the script scanned the log at its 10 minute interval.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

How can I get expected result here ?

By Akshay Hegde

Can Anyone help with looping…


awk 'FNR==1{i++}
{for(k=1; k<=NF; k++) A[i,FNR,k]=$k} # 3 Dimension Array
END{
for(i=1;i<=242;i++) # For loop 2nd File 1st and 2nd column
x=0;y=0 # Intialize x and y value 0
{
for(j=1;j<=2442;j++) # For loop for 1st file 1st and 2nd column
if(A[1,j,2]>=A[2,i,2]-0.1 && A[1,j,2]<=A[2,i,2]+0.1) # Comparison starts here
{
if(A[1,j,1]>=A[2,i,1])x=x+1;
if(A[1,j,1]<=A[2,i,1])y=y+1;
}
} # Internal loop ends here
if(x>=1 && y>=1)
print i,j,A[2,i,1],A[2,i,2]}' OFS="t" file1 file2 # 1st for loop ends here and printing

Result : coming
243 2443 74 10.33

Expected result :
1 2443 75.5 10.05
2 2443 75.02 10.15
3 2443 74.52 10.23


…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Can anyone tell me what's wrong with my script

By Akshay Hegde

here is my script…stored file1 data in array and comparing with second file..result is coming but wrong…in a sense..if I remove 1st line where I stored data in array, and store instead in some bash variable like

Code:

x=`{awk 'FNR{print $1}}' file1`


then result comes properly,but execution is very slow…

Code:

c=`awk 'END{print NR}'file1`
awk '{{getline< "file1";ln[NR]=$1; lt[NR]=$2}}
FNR<=NR{
l1=$1;
la1=$2;
p=la1+0.1;
m=la1-0.1;
x=0;
y=0;
{
for(j=1;j<='$c';j++)
if(lt[j]>=m && lt[j]<=p)
{
if(l1>=ln[j])
x=x+1
if(l1<=ln[j])
y=y+1
}
}
if(x>=1 && y>=1)
print l1,la1,"Wow you are safe..."
}' OFS="t" file2.dat


if anyone can tell where I am doing wrong, It will be helpful…

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Help with concatinating the data of 2 files

By ss_ss

Hi All,

I am trying to merge to 2 files 348.csv & 349.csv using join,awk commands but not getting proper output:

Code:


cat 348.csv
Timestamp Server
348
02/04/2013 09:19 100
02/04/2013 09:20 250
02/04/2013 09:21 80


Code:


cat 349.csv
Timestamp Server
349
02/04/2013 09:19 234
02/04/2013 09:20 13
02/04/2013 09:21 546


Code:


Expected output
Timestamp Server
348 349
02/04/2013 09:19 100 234
02/04/2013 09:20 250 13
02/04/2013 09:21 80 546


Code:


using below awk:
awk 'NR==FNR{i=NF<5?"__":$1$2$3$4;a[i]=$0;next} FNR==1{print}{i=NF1&&i in a{print a[i],$NF}' 348.csv 349.csv


Code:


using below join:
join -a1 -a2 348.csv 349.csv


Thanks,

Source: FULL ARTICLE at The UNIX and Linux Forums

Loop usage with counter

By Akshay Hegde

Hi friends, I just want to try some thing with shell using loop and counter

I have 30 Directory, in each directory number of files say 5, 10, 20 etc…

Code:

directory_1
directory_2
directory_n


what I want to do is read files from directory_1 say 5 files
if my counter is like this

Code:

m=2000 # M is for folder

n=1 # N is for file counter
for file in `ls *.dat |sort -t"_" -k2n,2`; do
awk -F, 'FNR == 1{print '$m',$1,$2,$3,'$n',$5,$6,$7}' OFS="," $file >>file.csv
n=$(( $n+1 ))
done


output wanted is something like this in single file comma separtated

Code:

column 1 column 2 $1 $2 $3 $..........$7
2000 1
2000 2
2000 3
2000 4
2000 5
2001 1
2001 2
2002 1


How can I use another counter in my script, also it has to read files from directory_1, directory_2 ….directory_n

Note : directory names are same only after

Code:

_


number is changing

so I think for this also one more counter is needed

Code:

something like this
x=1
cd directory_'x'

awk script

cd ..

increment x

cd directory_'x' # 2nd directory
awk script... so on


Source: FULL ARTICLE at The UNIX and Linux Forums