02-13-2020
It prints the line occurrence of column 1 ($1). a[$1]++ fails for the first occurrence increment since the array value for that key does not exist. The ! means not true so the expression is evaluated to true. The default action for true in awk is to print the line. In other terms: if the previous value of column 1 in array "a" cannot be incremented then print the line. The line could have been written as: '{if (! a[$1]++) print $0}'
Last edited by RavinderSingh13; 02-28-2020 at 01:42 AM..
This User Gave Thanks to rdrtx1 For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I want to print column value based on row number say multiple of 8.
Input file:
line 1 67 34
line 2 45 57
. . .
. . .
line 8 12 46
. . .
. . .
line 16 24 90
. . .
. . .
line 24 49 67
Output
46
90
67 (2 Replies)
Discussion started by: Surabhi_so_mh
2 Replies
2. Shell Programming and Scripting
Hello,
BC106081_abc_128240811_128241377 7.96301
BC106081_abc_128240811_128241377 39.322
BC106081_cde_128240811_128241377 1.98628
BC106081_def_128240811_128241377 -2.44492
BC106081_abc_128240811_128241377 69.5504
FLJ00075_xyz_14406_16765 -0.173417
... (3 Replies)
Discussion started by: Diya123
3 Replies
3. Shell Programming and Scripting
Is it possible to print max number of 2 columns - awk
note: print max if the integer is positive and print min if the integer is negative
input
a 1 2
b 3 4
c 5 1
d -3 -5
d -5 -3
output
a 2
b 4
c 5
d -5
d -5 (4 Replies)
Discussion started by: quincyjones
4 Replies
4. Shell Programming and Scripting
Dear All,
I have data like this,
input:
1254 10125
1254 10126
1254 10127
1254 10128
1254 10129
1255 10130
1255 10131
1255 10132
1255 10133
1256 10134
1256 10135
1256 10137... (3 Replies)
Discussion started by: aksin
3 Replies
5. UNIX for Dummies Questions & Answers
file with this content
awk 'NR==1 {print $4} && NR==2 {print $5}' file
The error is shown with syntax error; what can be done (4 Replies)
Discussion started by: cdfd123
4 Replies
6. Shell Programming and Scripting
Hi,
I have the following file,
chr1 100 200 20
chr1 201 300 22
chr1 220 345 23
chr1 230 456 33.5
chr1 243 567 90
chr1 345 600 20
chr1 430 619 21.78
chr1 870 910 112.3
chr1 914 920 12
chr1 930 999 13
My output would be
peak1 20 22 23 33.5 90
peak2 20 21.78 112.3 12 13
Here the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies
7. Shell Programming and Scripting
I have the input file in attached.
I want the output file :
Date , Time , Max_Bearer
11/01/2013 , 23:00 , 1447.894167
11/02/2013 , 00:00 , 1429.266667
11/03/2013 , 00:00 , 712.3175
11/04/2013 , 22:00 , 650.9533333
11/05/2013 , 23:00 , 665.9558333
11/06/2013 , 23:00 , 659.8616667... (2 Replies)
Discussion started by: justbow
2 Replies
8. Shell Programming and Scripting
Hi.
How can we print those rows of file2 which are mentioned in file1. first character of file1 is a row number.. for eg
file1
1:abc
3:ghi
6:pqr
file2
a abc
b def
c ghi
d jkl
e mno
f pqr
... (6 Replies)
Discussion started by: Abhiraj Singh
6 Replies
9. Shell Programming and Scripting
Dear All,
I have input :
SEG901 5173 9005 5740
SEG902 5227 5284
SEG903 5284 5346
SEG904 5346 9010
SEG905 5400 5456
SEG906 5456 5511
SEG907 5511 9011
SEG908 5572 9015
SEG909 5622 9020
SEG910 5678 5739
SEG911 5739 5796
SEG912 5796 9025 ... (3 Replies)
Discussion started by: attila
3 Replies
10. Shell Programming and Scripting
Hello Team,
Need your expertise on following:
Here is the set of data:
C1|4|C1SP1|A1|C1BP1|T1
C1|4|C1SP2|A1|C1BP2|T2
C2|3|C2SP1|A2|C2BP1|T2
C3|3|C3SP1|A3|C3BP1|T2
C2|2|C2SP2|A2|C2BP2|T1
I need to filter above date base on following two steps:
1. Group them by column 1 and 4
2.... (12 Replies)
Discussion started by: angshuman
12 Replies
LEARN ABOUT REDHAT
sgbequ
SGBEQU(l) ) SGBEQU(l)
NAME
SGBEQU - compute row and column scalings intended to equilibrate an M-by-N band matrix A and reduce its condition number
SYNOPSIS
SUBROUTINE SGBEQU( M, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND, AMAX, INFO )
INTEGER INFO, KL, KU, LDAB, M, N
REAL AMAX, COLCND, ROWCND
REAL AB( LDAB, * ), C( * ), R( * )
PURPOSE
SGBEQU computes row and column scalings intended to equilibrate an M-by-N band matrix A and reduce its condition number. R returns the row
scale factors and C the column scale factors, chosen to try to make the largest element in each row and column of the matrix B with ele-
ments B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.
R(i) and C(j) are restricted to be between SMLNUM = smallest safe number and BIGNUM = largest safe number. Use of these scaling factors is
not guaranteed to reduce the condition number of A but works well in practice.
ARGUMENTS
M (input) INTEGER
The number of rows of the matrix A. M >= 0.
N (input) INTEGER
The number of columns of the matrix A. N >= 0.
KL (input) INTEGER
The number of subdiagonals within the band of A. KL >= 0.
KU (input) INTEGER
The number of superdiagonals within the band of A. KU >= 0.
AB (input) REAL array, dimension (LDAB,N)
The band matrix A, stored in rows 1 to KL+KU+1. The j-th column of A is stored in the j-th column of the array AB as follows:
AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl).
LDAB (input) INTEGER
The leading dimension of the array AB. LDAB >= KL+KU+1.
R (output) REAL array, dimension (M)
If INFO = 0, or INFO > M, R contains the row scale factors for A.
C (output) REAL array, dimension (N)
If INFO = 0, C contains the column scale factors for A.
ROWCND (output) REAL
If INFO = 0 or INFO > M, ROWCND contains the ratio of the smallest R(i) to the largest R(i). If ROWCND >= 0.1 and AMAX is neither
too large nor too small, it is not worth scaling by R.
COLCND (output) REAL
If INFO = 0, COLCND contains the ratio of the smallest C(i) to the largest C(i). If COLCND >= 0.1, it is not worth scaling by C.
AMAX (output) REAL
Absolute value of largest matrix element. If AMAX is very close to overflow or very close to underflow, the matrix should be
scaled.
INFO (output) INTEGER
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
> 0: if INFO = i, and i is
<= M: the i-th row of A is exactly zero
> M: the (i-M)-th column of A is exactly zero
LAPACK version 3.0 15 June 2000 SGBEQU(l)