Sponsored Content
Top Forums Shell Programming and Scripting Matching options from ARGV in awk Post 302574783 by kristinu on Friday 18th of November 2011 10:21:39 AM
Old 11-18-2011
I have tried using the code below, but when I run

Code:
awk -f ./addNoise-dat.awk --exapls

I am getting

Code:
MATCH -e: 2 2 2
MATCH --examples: 0 0 -1

Seems it is matching on -e

Code:
  if ( match(ARGV[ARGC-1],"-e") || match(ARGV[ARGC-1],"--examples") ) {
    print "MATCH -e:",match(ARGV[ARGC-1],"-e"), RSTART, RLENGTH
    print "MATCH --examples:",match(ARGV[ARGC-1],"--examples"), RSTART, RLENGTH
    examples()
    exit(1)
  }

---------- Post updated at 10:21 AM ---------- Previous update was at 10:13 AM ----------

Yes, when I use as mentioned, things are fine.

Is there any way I can group /^-e$/ and /^--examples$/ with | inside match?

Code:
if ( match(ARGV[ARGC-1],/^-e$/) || match(ARGV[ARGC-1],/^--examples$/) )

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

options with awk

Hi everybody, I have some difficulties to use awk with the right options (as always): i have for example 3 fields: IF-MIB::ifIndex.1 IF-MIB::ifIndex.2 IF-MIB::ifIndex.3 i want to use "while" to access to these records one by one so i wrote this script but it didn t return the right value:... (2 Replies)
Discussion started by: mips
2 Replies

2. UNIX for Dummies Questions & Answers

argv command in awk

hello does anyone knows how can i reach a parameter in awk command line for example p1 f 4 p1 is an awk script. 4 is parameter i want to work with the second parameter i know it has something to do with argv command i just dont know the syntax. please help. (1 Reply)
Discussion started by: emil2006
1 Replies

3. Shell Programming and Scripting

print argv inside awk

mode=$1 psg telnetd | awk current=`date +%M`'{ printf ("mode is %s",mode) printf ("mode is %s",ARGV) }' at command prompt when i run the script along with the argument i get only-- 'mode is ' argument is not printed.(If the argument is... (3 Replies)
Discussion started by: Anteus
3 Replies

4. Shell Programming and Scripting

Awk and checking options

My task is that when the user calls the script 1. If user calls script with awk -v dtmax= -v stdlim= -f ../Scripts/add-rgauss-xt.awk fin.xt > fout.xt rgauss will return mean + (stdlim * sigma) 2. If user calls script with awk -v dtmax= -f ../Scripts/add-rgauss-xt.awk fin.xt > fout.xt... (4 Replies)
Discussion started by: kristinu
4 Replies

5. Shell Programming and Scripting

awk script file command line options

Being new to awk I have a really basic question. It just has to be in the archives but it didn't bite me when I went looking for it. I've written an awk script, placed it in a file, added the "#!/usr/bin/awk -f" at the top of the script and away I go. "% myAwk <inputfile>" gives me exactly what... (2 Replies)
Discussion started by: tomr2k
2 Replies

6. UNIX for Advanced & Expert Users

ISC DHCP ipv4 options and matching ipv6

Hi I am looking to set-up ISC DHCP to support ipv6, and to migrate my existing SUN DHCP ipv4 to ISC, finding the ipv4 options for the SUN DHCP options was ok eg TFTPsrvN = tftp-server-name OptBootF = bootfile-name However if I set up a DHCPv6 does anyone know what the equivalent... (0 Replies)
Discussion started by: eeisken
0 Replies

7. Shell Programming and Scripting

argc/ argv in awk

Hi guys, i'm trying to solve this problem. I have to run something like cat file1.txt | awk -f script.awk 10 if i'm in the awk script, how can i take the parameter :10 ??:wall: i try something like : BEGIN{ var=argv } {..} END{..} but obviously is not correct... (5 Replies)
Discussion started by: heaven25
5 Replies

8. UNIX for Advanced & Expert Users

O argv, argv, wherefore art thou argv?

All of my machines (various open source derivatives on x86 and amd64) store argv above the stack (at a higher memory address). I am curious to learn if any systems store argv below the stack (at a lower memory address). I am particularly interested in proprietary Unices, such as Solaris, HP-UX,... (9 Replies)
Discussion started by: alister
9 Replies

9. Shell Programming and Scripting

awk to combine all matching dates and remove non-matching

Using the awk below I am able to combine all the matching dates in $1, but I can not seem to remove the non-matching from the file. Thank you :). file 20161109104500.0+0000,x,5631 20161109104500.0+0000,y,2 20161109104500.0+0000,z,2 20161109104500.0+0000,a,4117... (3 Replies)
Discussion started by: cmccabe
3 Replies
All times are GMT -4. The time now is 01:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy