Sponsored Content
Full Discussion: using array inside awk
Top Forums Shell Programming and Scripting using array inside awk Post 302222647 by subin_bala on Thursday 7th of August 2008 09:07:52 AM
Old 08-07-2008
using array inside awk

Hi All,

I have the following code sequence for reading some bulk file and moving the content to two different arrays.

while read data
do
THREEG_PATTERN=`echo $data | egrep "3G"`
if [ "$data" == "$THREEG_PATTERN" ]
then
NEW_THREEG_PATTERN=`echo $THREEG_PATTERN | cut -d " " -f2`
THREEG_ARRAY[$IDX]=$NEW_THREEG_PATTERN
IDX=$(($IDX+1))
else
SP_ARRAY[$IDX_SP]=$data
IDX_SP=$(($IDX_SP+1))
fi

done < $_pat


This code is working perfectly but this is taking long time because of big file size.... How can i improve the performance of this process by using awk or other mechanism? Or how can i convert this entire code to awk? Looking forward ur reply

Thanks in advance
Subin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

looping a array inside inside ssh is not working, pls help

set -A arr a1 a2 a3 a4 # START ssh -xq $Server1 -l $Username /usr/bin/ksh <<-EOS integer j=0 for loop in ${arr} do printf "array - ${arr}\n" (( j = j + 1 )) j=`expr j+1` done EOS # END ========= this is not giving me correct output. I... (5 Replies)
Discussion started by: reldb
5 Replies

2. UNIX for Advanced & Expert Users

Array inside an array

hi All, I have a array as follows, array1=("xx" "abc" "def" "xyz") and each array1 is also storing some array values, like array1=abc and abc=("a" "b" "c") etcetera etcetra......... Note : each subarray under array1 have index 3 i.e. it can max contain 3 values if i echo ${abc} ... (5 Replies)
Discussion started by: manas_ranjan
5 Replies

3. Shell Programming and Scripting

split and making an array inside another array

I want to run an awk split on a value that has been pushed through an array and I was wondering what the syntax should be?? e.g. running time strings through an array and trying to examine just minutes: 12:25:30 10:15:13 08:55:23 awk ' NR==FNR{ ... (2 Replies)
Discussion started by: dcfargo
2 Replies

4. Shell Programming and Scripting

printing array elements inside AWK

i just want to dump my array and see if it contains the values i am expecting. It should print as follows, ignore=345fht ignore=rthfg56 . . . ignore=49568g Here is the code. Is this even possible to do? please help termReport.pl < $4 | dos2ux | head -2000 | awk ' BEGIN... (0 Replies)
Discussion started by: usustarr
0 Replies

5. Shell Programming and Scripting

Calling array inside awk

Hello I have the file df.tmp FS is actually the / FS but escape character\ and end of line $ is used in order to fetch exctly / and not other filesystems. awk '/\/$/ {print $(NF-1)+0}' df.tmp will work properly and return a value eg. 60 but when I am trying to issue the command with the array... (3 Replies)
Discussion started by: drbiloukos
3 Replies

6. Shell Programming and Scripting

unique inside array

I have a file root@server # cat /root/list12 11.22.33.44 22.33.44.55 33.44.55.66 33.44.55.66 33.44.55.66 I try to pass to array and display unique. root@server# cat /root/test12.sh #!/bin/bash #delcare array badips and accumulate values to array elemenrs badips=( $( cat... (4 Replies)
Discussion started by: anil510
4 Replies

7. Shell Programming and Scripting

HELP with AWK one-liner. Need to employ an If condition inside AWK to check for array variable ?

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)
Discussion started by: shell_boy23
6 Replies

8. Shell Programming and Scripting

How to use variable inside array?

I tried to use variable inside an array variable, but its not working as expected.:wall: ENV1=123 ENV1=789 ENV1=120 ENV2=567 if then name=ENV1 echo "${name}" echo "${name}" echo "${name}" else name=ENV1 echo "${name}" fi Output: ./val.sh 1 123 (2 Replies)
Discussion started by: Jayavinoth
2 Replies

9. UNIX for Dummies Questions & Answers

Array inside sed

Hi guys Let me at first describe the whole thing that I'm trying to do. Lets say I have 100 files like the following one. Ow 1230 16.000000 -0.834000 16.083957 1.751652398 -17.20094528 -4.450623277 Hw 1231 ... (6 Replies)
Discussion started by: saleheen
6 Replies

10. UNIX for Beginners Questions & Answers

sed inside the awk script to replace a string in the array

The requirement is i need to find an array value matching with pattern {5:{ , replace that with 5: and reassign that to same array index and print it. I write something like below and the issue is sed command is not working. If i replace " with "`" the script gives syntax error.how can i... (8 Replies)
Discussion started by: bhagya123
8 Replies
dlasd2.f(3)							      LAPACK							       dlasd2.f(3)

NAME
dlasd2.f - SYNOPSIS
Functions/Subroutines subroutine dlasd2 (NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT, LDVT, DSIGMA, U2, LDU2, VT2, LDVT2, IDXP, IDX, IDXC, IDXQ, COLTYP, INFO) DLASD2 Function/Subroutine Documentation subroutine dlasd2 (integerNL, integerNR, integerSQRE, integerK, double precision, dimension( * )D, double precision, dimension( * )Z, double precisionALPHA, double precisionBETA, double precision, dimension( ldu, * )U, integerLDU, double precision, dimension( ldvt, * )VT, integerLDVT, double precision, dimension( * )DSIGMA, double precision, dimension( ldu2, * )U2, integerLDU2, double precision, dimension( ldvt2, * )VT2, integerLDVT2, integer, dimension( * )IDXP, integer, dimension( * )IDX, integer, dimension( * )IDXC, integer, dimension( * )IDXQ, integer, dimension( * )COLTYP, integerINFO) DLASD2 Purpose: DLASD2 merges the two sets of singular values together into a single sorted set. Then it tries to deflate the size of the problem. There are two ways in which deflation can occur: when two or more singular values are close together or if there is a tiny entry in the Z vector. For each such occurrence the order of the related secular equation problem is reduced by one. DLASD2 is called from DLASD1. Parameters: NL NL is INTEGER The row dimension of the upper block. NL >= 1. NR NR is INTEGER The row dimension of the lower block. NR >= 1. SQRE SQRE is INTEGER = 0: the lower block is an NR-by-NR square matrix. = 1: the lower block is an NR-by-(NR+1) rectangular matrix. The bidiagonal matrix has N = NL + NR + 1 rows and M = N + SQRE >= N columns. K K is INTEGER Contains the dimension of the non-deflated matrix, This is the order of the related secular equation. 1 <= K <=N. D D is DOUBLE PRECISION array, dimension(N) On entry D contains the singular values of the two submatrices to be combined. On exit D contains the trailing (N-K) updated singular values (those which were deflated) sorted into increasing order. Z Z is DOUBLE PRECISION array, dimension(N) On exit Z contains the updating row vector in the secular equation. ALPHA ALPHA is DOUBLE PRECISION Contains the diagonal element associated with the added row. BETA BETA is DOUBLE PRECISION Contains the off-diagonal element associated with the added row. U U is DOUBLE PRECISION array, dimension(LDU,N) On entry U contains the left singular vectors of two submatrices in the two square blocks with corners at (1,1), (NL, NL), and (NL+2, NL+2), (N,N). On exit U contains the trailing (N-K) updated left singular vectors (those which were deflated) in its last N-K columns. LDU LDU is INTEGER The leading dimension of the array U. LDU >= N. VT VT is DOUBLE PRECISION array, dimension(LDVT,M) On entry VT**T contains the right singular vectors of two submatrices in the two square blocks with corners at (1,1), (NL+1, NL+1), and (NL+2, NL+2), (M,M). On exit VT**T contains the trailing (N-K) updated right singular vectors (those which were deflated) in its last N-K columns. In case SQRE =1, the last row of VT spans the right null space. LDVT LDVT is INTEGER The leading dimension of the array VT. LDVT >= M. DSIGMA DSIGMA is DOUBLE PRECISION array, dimension (N) Contains a copy of the diagonal elements (K-1 singular values and one zero) in the secular equation. U2 U2 is DOUBLE PRECISION array, dimension(LDU2,N) Contains a copy of the first K-1 left singular vectors which will be used by DLASD3 in a matrix multiply (DGEMM) to solve for the new left singular vectors. U2 is arranged into four blocks. The first block contains a column with 1 at NL+1 and zero everywhere else; the second block contains non-zero entries only at and above NL; the third contains non-zero entries only below NL+1; and the fourth is dense. LDU2 LDU2 is INTEGER The leading dimension of the array U2. LDU2 >= N. VT2 VT2 is DOUBLE PRECISION array, dimension(LDVT2,N) VT2**T contains a copy of the first K right singular vectors which will be used by DLASD3 in a matrix multiply (DGEMM) to solve for the new right singular vectors. VT2 is arranged into three blocks. The first block contains a row that corresponds to the special 0 diagonal element in SIGMA; the second block contains non-zeros only at and before NL +1; the third block contains non-zeros only at and after NL +2. LDVT2 LDVT2 is INTEGER The leading dimension of the array VT2. LDVT2 >= M. IDXP IDXP is INTEGER array dimension(N) This will contain the permutation used to place deflated values of D at the end of the array. On output IDXP(2:K) points to the nondeflated D-values and IDXP(K+1:N) points to the deflated singular values. IDX IDX is INTEGER array dimension(N) This will contain the permutation used to sort the contents of D into ascending order. IDXC IDXC is INTEGER array dimension(N) This will contain the permutation used to arrange the columns of the deflated U matrix into three groups: the first group contains non-zero entries only at and above NL, the second contains non-zero entries only below NL+2, and the third is dense. IDXQ IDXQ is INTEGER array dimension(N) This contains the permutation which separately sorts the two sub-problems in D into ascending order. Note that entries in the first hlaf of this permutation must first be moved one position backward; and entries in the second half must first have NL+1 added to their values. COLTYP COLTYP is INTEGER array dimension(N) As workspace, this will contain a label which will indicate which of the following types a column in the U2 matrix or a row in the VT2 matrix is: 1 : non-zero in the upper half only 2 : non-zero in the lower half only 3 : dense 4 : deflated On exit, it is an array of dimension 4, with COLTYP(I) being the dimension of the I-th type columns. INFO INFO is INTEGER = 0: successful exit. < 0: if INFO = -i, the i-th argument had an illegal value. Author: Univ. of Tennessee Univ. of California Berkeley Univ. of Colorado Denver NAG Ltd. Date: November 2011 Contributors: Ming Gu and Huan Ren, Computer Science Division, University of California at Berkeley, USA Definition at line 268 of file dlasd2.f. Author Generated automatically by Doxygen for LAPACK from the source code. Version 3.4.1 Sun May 26 2013 dlasd2.f(3)
All times are GMT -4. The time now is 02:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy