Sponsored Content
Full Discussion: passing argument into awk
Top Forums Shell Programming and Scripting passing argument into awk Post 302105403 by prkfriryce on Thursday 1st of February 2007 01:24:02 PM
Old 02-01-2007
passing argument into awk

i'm trying to pass a numerical argument with function xyz to print specfic lines of filename, but my 'awk' syntax is incorrect.
ie

xyx 3 (prints the 3rd line, separated by ':' of filename)

Code:
function xyz() {
arg1=$1
cat filename | awk -F: -v x=$arg1 '{print $x}'
}

any ideas?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Passing argument to awk script

I am writing a shell script. Now i need to read in a string and send it to an awk file to compare and search for compatible record. I wrote it like tat: read serial | awk -f generate.awk data.dat p/s: the data file got 6 field. According to an expert, we can write it like tat: read... (1 Reply)
Discussion started by: AkumaTay
1 Replies

2. Shell Programming and Scripting

passing Argument

Hi All, i have script like below.. echo "1) first option" echo "" echo "2) second option" echo "" echo "*) please enter the correct option" read select case $select in 1) echo "first option selected" ;; 2) echo "second option selected" ;; *) echo "please enter the correct... (4 Replies)
Discussion started by: Shahul
4 Replies

3. Shell Programming and Scripting

Passing non Awk Argument in Awk

Dear Conerned, I am facing a situation where i need to pass an argument which is non-awk variable like day=090319 awk '/TID:R/ && /TTIN:/' transaction.log I want to add this day variable like below awk '/TID:R$day/ && /TTIN:/' transaction.log But it is not working. :confused: (1 Reply)
Discussion started by: saifurshaon
1 Replies

4. Shell Programming and Scripting

"Again passing argument to awk" !!

hi, I have this script #!/usr/bin/awk -v var1=1 -f $17==31 END{ { print $0 } } exit i am passing a file name from the command line now i want to make the 17th field value to be passed from command line. How can i do that, (1 Reply)
Discussion started by: aryasoumen
1 Replies

5. Shell Programming and Scripting

passing argument from Cshelll to awk command

Hi all I have got a file digits.data containing the following data 1 3 4 2 4 9 7 3 1 7 3 10 I am writing a script that will pass an argument from C-shell to nawk command. But it seems the values in the nawk comman does not get set. the program does not print no values out. Here is the... (1 Reply)
Discussion started by: ganiel24
1 Replies

6. Shell Programming and Scripting

Passing argument to system call in awk script

So, I have this script. It reads a CSV file that has a mixture of object names with IP addresses (parsing out that part I have working), and object names which have a DNS name. I want to be able to run a "dig +short" based off of the name given to me in the line of the awk script, and then deal... (6 Replies)
Discussion started by: mikesimone
6 Replies

7. Shell Programming and Scripting

Problem passing directory as argument with awk

I'm trying to figure out what's getting passed as the argument when I try to pass a directory as an argument, and I'm getting incredibly strange behavior. For example, from the command line I'm typing: nawk -f ./test.awk ~ test.awk contains the following: { directory = $NF print... (13 Replies)
Discussion started by: mrplainswalker
13 Replies

8. Shell Programming and Scripting

Passing value as a command line argument in awk script.

I have one working awk command line. Which taking data from the “J1202523.TXT” file and generating the “brazil.dat” file. PFB code. awk '{ DUNS = substr($0,0,9);if ( substr($0,14,3) == "089" ) print DUNS }' J1202523.TXT > Brazil.dat But now I want to pass two parameter as a command line argument... (4 Replies)
Discussion started by: humaemo
4 Replies

9. Shell Programming and Scripting

Passing --usage as argument to awk script

I have the awk script below and things go wrong when I do awk -v dsrmx=25 -f ./checkSRDry.awk --usage I basically want to override the usual --usage and --help that awk gives. How do people usually handle this situation when you also want to supply your own usage and help concerning the... (2 Replies)
Discussion started by: kristinu
2 Replies

10. Shell Programming and Scripting

Passing awk variable argument to a script which is being called inside awk

consider the script below sh /opt/hqe/hqapi1-client-5.0.0/bin/hqapi.sh alert list --host=localhost --port=7443 --user=hqadmin --password=hqadmin --secure=true >/tmp/alerts.xml awk -F'' '{for(i=1;i<=NF;i++){ if($i=="Alert id") { if(id!="") if(dt!=""){ cmd="sh someScript.sh... (2 Replies)
Discussion started by: vivek d r
2 Replies
NIP2(1) 						      General Commands Manual							   NIP2(1)

NAME
nip2 - image processing with the VIPS library SYNOPSIS
nip2 [filename1 ...] nip2 -s filename [arg1 ...] nip2 -e expression [arg1 ...] DESCRIPTION
nip2 (for New Image Processing) is a tool for manipulating images using the VIPS image processing library. There are three principal modes: nip2 [filename1 ...] start in GUI mode, loading the named files nip2 -e expression [arg1 ...] nip2 --expression=EXPRESSION [arg1 ...] start in no-GUI mode; set main = expression, set list argv to ["filename", "arg1", "arg2", ...], set argc to length of list; print the value of symbol "main" to stdout; exit nip2 -s filename [arg1 ...] nip2 --script=FILENAME [arg1 ...] start in no-GUI mode; read in filename as a set of definitions, set list argv to ["filename", "arg1", "arg2", ...], set argc to length of list; print the value of symbol "main" to stdout; exit; useful for running nip2 as an interpreter on unix You can use -o to direct output to a file rather than stdout. -o filename --output=FILENAME the value of main is written to the named file. If main is a list, the filename is incremented between objects. You can use the suffix to specify the format and options to write in Other options provide finer control over startup and shutdown. If you need to do something strange, don't use -e/-s, use these in combina- tion. -b --batch batch (ie. non-GUI) mode -m --no-load-menus don't load menus, for faster startup -a --no-load-args don't load extra command-line arguments -w --stdin-ws load stdin as a workspace -d --stdin-def load stdin as a set of definitions -p --print-main print the value of main on exit. nip2 will check for a top-level symbol called main, and also check each workspace for a main Finally some other options are useful for debugging, timing and for generating strings for internationalisation. -V --verbose produce verbose error messages: handy for debugging in batch mode -i --i18n output strings from .def files for internationalisation -v --version print version information -c --benchmark benchmark: no GUI, just start up and shut down -t --time-save time saves: after every image save a popup tells you the time the save took in seconds -T --test test: start up (including any arg processing), test for any errors, and exit with an error code if any occured. Useful for running automated tests. -x PREFIX --prefix=PREFIX set install prefix: start up as if nip2 had been installed to PREFIX. Useful for running automated tests without installing the thing. EXAMPLES
nip2 fred.jpg Start nip2, loading fred.jpg. nip2 -e "2 + 2" Prints 4 to stdout. nip2 -e "99 + Image_file argv?1" -o result.png fred.jpg Load argv1 (fred.jpg), add 99, output to result.png. nip2 -e "Matrix [[1,2],[4,5]] ** -1" -o poop.mat Invert the 2x2 matrix and write the result to poop.mat. COPYRIGHT
2008 (c) Imperial College, London Oct 4 2004 NIP2(1)
All times are GMT -4. The time now is 03:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy