Sponsored Content
Top Forums Shell Programming and Scripting Pass command line arguments to awk Post 302380501 by kristinu on Tuesday 15th of December 2009 10:31:46 AM
Old 12-15-2009
I'm doing like below

Code:
awk -f txsrx.awk jcd.tx 40 > temp

Did not delete the arg containing the 40 so it is tying to open it as a file.

Doing it like this seems to work

Code:
BEGIN {
#    ARGV[ARGC++] = ARGV[ARGC-1]
    print "0." ARGV[0]
    print "1." ARGV[1]
    print "2." ARGV[2]
    print ""
    max = ARGV[ARGC-1]
    # Delete args so awk does not open them as files
    ARGV[ARGC-1] = ARGV[1]
    print ARGC
    print "0." ARGV[0]
    print "1." ARGV[1]
    print "2." ARGV[2]
    print "3." ARGV[3]
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using command line arguments as columns for pattern matching using awk

Hi, I wish to use a column, as inputted by a user from command line, for pattern matching. awk file: { if($1 ~ /^8/) { print $0> "temp2.csv" } } something like this, but i want '$1' to be any column as selected by the user from command line. ... (1 Reply)
Discussion started by: invinclible0009
1 Replies

2. Shell Programming and Scripting

How do we pass multiple arguments into awk

How do we pass multiple arguments into awk : name=john age=12 now i have to pass both age and name into awk.. how to do it? like : awk -v var=... (4 Replies)
Discussion started by: abhinav192
4 Replies

3. Shell Programming and Scripting

How can i pass 2 command line arguments with a range between them

Hi, I am writting a script. i am not sure what i am trying to do is possible or not. thats why asking the best of the best. the script i want to write will recieve as input parameters 2 different options. as in MODE 1 -- start_date / end_date (2 dates has 2 go at a time MODE 2... (2 Replies)
Discussion started by: dazdseg
2 Replies

4. Programming

How to pass the command line arguments to the shell script in c language?

hi, I am new in the shell script, and c programming with linux. I am looking to pass the arguments in c program that should be executed by the shell script. e.g. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { int i; for (i=1;i<argc; i++) { ... (2 Replies)
Discussion started by: sharlin
2 Replies

5. Shell Programming and Scripting

Pass awk field to a command line executed within awk

Hi, I am trying to pass awk field to a command line executed within awk (need to convert a timestamp into formatted date). All my attempts failed this far. Here's an example. It works fine with timestamp hard-codded into the command echo "1381653229 something" |awk 'BEGIN{cmd="date -d... (4 Replies)
Discussion started by: tuxer
4 Replies

6. Shell Programming and Scripting

How can I pass arguments to system command in a awk script?

Hi I need your help, please How can I pass arguments to system command in a awk script?... for example: byte=substr(cadena,pos,2); system("grep -n byte mapeo.txt"); Does it exist a way? Thanks for advance. (4 Replies)
Discussion started by: solaris21
4 Replies

7. Shell Programming and Scripting

Need to pass shell arguments into Nawk/awk

Hi, I am in critical need of help, Thanks a ton for your help. I need to know how to pass the shell argument into nawk code in AIX. so that my file gets passed into that awk script and it can execute it part. To be detail, i have more than 100 files and in those files a particular field... (6 Replies)
Discussion started by: Selva_2507
6 Replies

8. Shell Programming and Scripting

How to pass command line arguments to awk program?

#!/bin/awk -f BEGIN { FS=":"; } { if ( $7 == "" ) { print $1 ": no password!"; } } I want to execute this program for a particular user to check for his password from the file /etc/passwd (as the input file) and the user details to be given... (1 Reply)
Discussion started by: sri.phani
1 Replies

9. Shell Programming and Scripting

awk command line arguments not taking

# more minusf.awk #!/bin/awk -f BEGIN { FS=":"; } { if ( $2 == "" ) { print $1 ": no password!"; } } # ./minusf.awk aa aa aa aa awk: can't open aa (6 Replies)
Discussion started by: sri.phani
6 Replies

10. Shell Programming and Scripting

Read file lines and pass line values as arguments.

Dears, Need help to implement below requirement A file (detail.txt)contain : 1st column: Stream 2nd column: PathAddress 3rd column: Counterlimit 4th column: TransactionDateColumn 5th column: DateType 6th column: SleepValue 7th column: Status Need to write a... (1 Reply)
Discussion started by: sadique.manzar
1 Replies
ExtUtils::Command::MM(3)				User Contributed Perl Documentation				  ExtUtils::Command::MM(3)

NAME
ExtUtils::Command::MM - Commands for the MM's to use in Makefiles SYNOPSIS
perl "-MExtUtils::Command::MM" -e "function" "--" arguments... DESCRIPTION
FOR INTERNAL USE ONLY! The interface is not stable. ExtUtils::Command::MM encapsulates code which would otherwise have to be done with large "one" liners. Any $(FOO) used in the examples are make variables, not Perl. test_harness test_harness($verbose, @test_libs); Runs the tests on @ARGV via Test::Harness passing through the $verbose flag. Any @test_libs will be unshifted onto the test's @INC. @test_libs are run in alphabetical order. pod2man pod2man( '--option=value', $podfile1 => $manpage1, $podfile2 => $manpage2, ... ); # or args on @ARGV pod2man() is a function performing most of the duties of the pod2man program. Its arguments are exactly the same as pod2man as of 5.8.0 with the addition of: --perm_rw octal permission to set the resulting manpage to And the removal of: --verbose/-v --help/-h If no arguments are given to pod2man it will read from @ARGV. If Pod::Man is unavailable, this function will warn and return undef. warn_if_old_packlist perl "-MExtUtils::Command::MM" -e warn_if_old_packlist <somefile> Displays a warning that an old packlist file was found. Reads the filename from @ARGV. perllocal_install perl "-MExtUtils::Command::MM" -e perllocal_install <type> <module name> <key> <value> ... # VMS only, key|value pairs come on STDIN perl "-MExtUtils::Command::MM" -e perllocal_install <type> <module name> < <key>|<value> ... Prints a fragment of POD suitable for appending to perllocal.pod. Arguments are read from @ARGV. 'type' is the type of what you're installing. Usually 'Module'. 'module name' is simply the name of your module. (Foo::Bar) Key/value pairs are extra information about the module. Fields include: installed into which directory your module was out into LINKTYPE dynamic or static linking VERSION module version number EXE_FILES any executables installed in a space seperated list uninstall perl "-MExtUtils::Command::MM" -e uninstall <packlist> A wrapper around ExtUtils::Install::uninstall(). Warns that uninstallation is deprecated and doesn't actually perform the uninstallation. perl v5.16.3 2013-06-14 ExtUtils::Command::MM(3)
All times are GMT -4. The time now is 09:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy