printing array elements inside AWK


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting printing array elements inside AWK
# 1  
Old 04-20-2010
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[0]=345fht
ignore[1]=rthfg56
.
.
.
ignore[n]=49568g

Here is the code. Is this even possible to do? please help



Code:
 
termReport.pl < $4 | dos2ux |  head -2000 | awk '
    BEGIN { foundTermEvent=0;
            endMarker="'"${endMarker}"'"; }
    {
      if ( (substr($0, 1, length(endMarker)) == endMarker) ||
           (substr($0, 1, 39) == "'${SBINDIR}'/termReport.pl: ") )
      {
        if (foundTermEvent == 1)
        {
          print "";
          foundTermEvent=0;
        }
      }
      if (foundTermEvent == 1)
      {
            z=0
            while ( z <= leanth_of_ignore )
            {
                if ( ignore[z] == $2 )
               {
               foundTermEvent = 0;
               { print ignore[z] }
               z=31
               }
               else
               {
               print;
               { print ignore[z] }
               z++
               }
            }
      }
      if (substr($0, 1, 18) == "Termination Event:")
      {
        foundTermEvent=1;
      }
    }'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing array elements in reverse

Hello Experts, I am trying to print an array in reverse. Input : 1. Number of array elements 2. The array. Eg: 4 1 2 3 4 Expected Output (elements separated by a space) : 4 3 2 1 My Code : (6 Replies)
Discussion started by: H squared
6 Replies

2. Shell Programming and Scripting

Awk: Append new elements to an array

Hi all, I'm dealing with a bash script to merge the elements of a set of files and counting how many times each element is present. The last field is the file name. Sample files: head -5 *.tab==> 3J373_P15Ac1y2_01_LS.tab <== chr1 1956362 1956362 G A hom ... (7 Replies)
Discussion started by: lsantome
7 Replies

3. UNIX for Dummies Questions & Answers

printing array elements

Is there a way to print multiple array elements without iterating through the array using bash? Can you do something like... echo ${array}and get all those separate elements from the array? (2 Replies)
Discussion started by: jrymer
2 Replies

4. 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

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

Match elements in an AWK multi-dimensional array

Hello, I have two files in the following format; file1: A B C D E F G H I J K L file2: 1 2 3 4 5 6 7 8 9 10 11 12 I have read them both in to multi-dimensional arrays. I need a file that has column 2 of the first file printed out for each column 3 of the second file ie... ... (3 Replies)
Discussion started by: cold_Que
3 Replies

7. Shell Programming and Scripting

AWK help: how to compare array elements against a variable

i have an array call ignore. it is set up ignore=34th56 ignore=re45ty ignore=rt45yu . . ignore=rthg34 n is a variable. I have another variable that i read from a different file. It is $2 and it is working the way i expect. array ignore read and print correct values. in the below if... (2 Replies)
Discussion started by: usustarr
2 Replies

8. Shell Programming and Scripting

awk - array elements as condition

Hi, can I use array elements ( all ) in conditional statements? the problem is ,the total number of elements is not known. e.g A is an array with elements - 1,2,3 now if i want to test if the 1 st field of input record is either 1,2 or 3, i can do something like this if ( $1 ~... (1 Reply)
Discussion started by: shellwell
1 Replies

9. Shell Programming and Scripting

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 then NEW_THREEG_PATTERN=`echo $THREEG_PATTERN | cut -d " " -f2` ... (12 Replies)
Discussion started by: subin_bala
12 Replies

10. Shell Programming and Scripting

Accessing single elements of a awk array in END

How do I access one of the indices in array tst with the code below? tst=sprintf("%5.2f",Car / 12) When I scan thru the array with for ( i in tst ) { print i,tst } I get the output of: vec-7 144 But when I try this in the END print tst It looks like it's not set. What am... (6 Replies)
Discussion started by: timj123
6 Replies
Login or Register to Ask a Question
MP3CHECK(1)						      General Commands Manual						       MP3CHECK(1)

NAME
mp3check - check mp3 files for consistency SYNOPSIS
mp3check [-03ABCEFGIKLMNPRSTWYZabcdefghlmopqrst] [--accept=LIST] [--alt-color] [--anomaly-check] [--any-bitrate] [--any-crc] [--any-empha- sis] [--any-layer] [--any-mode] [--any-sampling] [--any-version] [--ascii-only] [--color] [--compact-list] [--cut-junk-end] [--cut-junk- start] [--cut-tag-end] [--dummy] [--dump-tag] [--dump-header] [--dump-tag] [--edit-frame-byte=P] [--error-check] [--error-check] [--filelist=FILE] [--fix-crc] [--fix-headers] [--help] [--ign-bitrate-sw] [--ign-constant-sw] [--ign-crc-error] [--ign-junk-end] [--ign- junk-start] [--ign-non-ampeg] [--ign-resync] [--ign-tag128] [--ign-truncated] [--list] [--log-file=FILE] [--max-errors=NUM] [--only-mp3] [--print-files] [--progress] [--quiet] [--raw-elem-sep=NUM] [--raw-line-sep=NUM] [--raw-list] [--recursive] [--reject=LIST] [--show-valid] [--single-line] [--version] [--xdev] [--] [FILES...] DESCRIPTION
This manual page documents briefly the mp3check command. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. mp3check is a program that checks mp3 files for consistency and prints several errors and warnings. It lists stream attributes (color). Layer 1,2,3, mpeg1.0+2.0 are currently supported. CRC check for layer 3. mp3check is very useful for incomplete mp3 detection as it can be used to scan through your mp3 collection and find all mp3s that aren't perfect. Good for use with Napster and other bulk downloading of mp3s. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). Options can be specified in any order and mixed with files. Option scanning stops after a double dash (--) to allow files beginning with a dash. A summary of options is included below. mode: -l --list list parameters by examining the first valid header and size -c --compact-list list parameters of one file per line in a very compact format: version (l=1.0, L=2.0), layer, sampling frequency [kHz] (44=44.1), bitrate [kbit/s], mode (js=joint stereo, st=stereo, sc=single channel, dc=dual channel), emphasis (n=none, 5=50/15 usecs, J=CCITT J.17), COY (has [C]rc, [O]riginal, cop[Y]right), length [min:sec], filename (poss. truncated) -e --error-check check crc and headers for consistency and print several error messages -m --max-errors=<int> with -e: set maximum number of errors to print per file (0==infinity) (range=[0..]) -a --anomaly-check report all differences from these parameters: layer 3, 44.1kHz, 128kbps, joint stereo, no emphasis, has crc -d --dump-header dump all possible header with sync=0xfff -t --dump-tag dump all possible tags of known version --raw-list list parameters in raw output format for use with external programs --raw-elem-sep=NUM separate elements in one line by char NUM (numerical ASCII code) (default="0x09") --raw-line-sep=NUM separate lines by char NUM (numerical ASCII code) (default="0x0a") --edit-frame-byte=P modify a single byte of a specific frame at a specific offset; B has the format 'frame,offset,byteval', (use 0xff for hex or 255 for dec or 0377 for octal); this mode operates on all given files and is useful for your own experiment with broken streams or while testing this toll ;-) fix errors: --cut-junk-start remove junk before first frame --cut-junk-end remove junk after last frame --fix-headers fix invalid headers (prevent constant parameter switching), implies -e, use with care --fix-crc fix crc (set crc to the calculated one), implies -e, use with care (note: it is not possible to add crc to files which have been created without crc) disable error messages for -e --error-check: -G --ign-tag128 ignore 128 byte TAG after last frame -R --ign-resync ignore invalid frame header -E --ign-junk-end ignore junk after last frame -Z --ign-crc-error ignore crc errors -N --ign-non-ampeg ignore non audio mpeg streams -T --ign-truncated ignore truncated last frames -S --ign-junk-start ignore junk before first frame -B --ign-bitrate-sw ignore bitrate switching and enable VBR support -W --ign-constant-sw ignore switching of constant parameters, such as sampling frequency --show-valid print the message 'valid audio mpeg stream' for all files which error free (after ignoring errors) disable anomaly messages for -a --anomaly-check: -C --any-crc ignore crc anomalies -M --any-mode ignore mode anomalies -L --any-layer ignore layer anomalies -K --any-bitrate ignore bitrate anomalies -I --any-version ignore version anomalies -F --any-sampling ignore sampling frequency anomalies -P --any-emphasis ignore emphasis anomalies file options: -r --recursive process any given directories recursively (the default is to ignore all directories specified on the command line) -f --filelist=FILE process all files specified in FILE (one filename per line) in addition to the command line -A --accept=LIST process only files with filename extensions specified by comma separated LIST -R --reject=LIST do not process files with a filename extension specified by comma separated LIST -3 --only-mp3 same as --accept mp3,MP3 --xdev do not descend into other filesystems when recursing directories (doesn't work in Cygwin environment) --print-files just print all filenames without processing them, then exit output options: -s --single-line print one line per file and message instead of splitting into several lines --no-summary suppress the summary printed below all messages if multiple files are given -g --log-file=FILE print names of erroneous files to FILE, one per line -q --quiet quiet mode, hide messages about directories, non-regular or non-existing files -o --color colorize output with ANSI sequences -b --alt-color colorize: do not use bold ANSI sequences --ascii-only generally all unprintable characters in filenames etc are replaced by '!' (ASCII 0-31) and '?' (ASCII 127-159), with this option present the range ASCII 160-255 (which is usually printable: e.g. ISO-8859) is also printed as '?' -p --progress show progress information on stderr common options: -0 --dummy do not write/modify anything other than the logfile -h --help print this help message, then exit successfully --version print version, then exit successfully AUTHOR
This original manual page was written by Klaus Kettner <kk@debian.org>, for the Debian GNU/Linux system. The current version of this man- page is maintained by Johannes Overmann <overmann@iname.com>, the author of mp3check. March 1, 2001 MP3CHECK(1)