awk parameters check


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk parameters check
# 1  
Old 05-11-2009
awk parameters check

Is there a way to preform check if the parameters that was send with the command awk -f `file_name.awk` `input_file` before even it gets to the BEGIN section (i have tested a try to check in the BEGIN it doesn't let ,you must make it on the section that after the BEGIN) and then decide if the script runs or not?
# 2  
Old 05-11-2009
You can check the variables ARGC and ARGV[] in the BEGIN section.
ARGC gives the number of arguments and ARGV[] is an array of the arguments, try them out.

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do i check if all parameters are set in bash?

Hi, I have 4 parameters passed to my shell and i validate if all four are entered using the following snippet: if then echo "Not entered" else echo "entered" fi I get the following output as 'Not entered even when i enter the values for all prompts. Please advise. Thanks. (5 Replies)
Discussion started by: Jesshelle David
5 Replies

2. Shell Programming and Scripting

help with awk with changing parameters: TY

hi, i got several pieces of code that look like: for ff in `seq 3 $nlpN`; do npc1=`awk 'NR=='$ff' {print $1}' p_walls.raw`; echo ${npc1}; npc2=`awk 'NR=='$ff' {print $2}' p_walls.raw`; npc3=`awk 'NR=='$ff' {print $3}' p_walls.raw`; npRs=`awk 'NR=='$ff' {print $4}'... (10 Replies)
Discussion started by: calim_cfd
10 Replies

3. Shell Programming and Scripting

check parameters

hi all, i write a script in ksh but i have a problem I want to check the number of parameters while ] do echo "Inserisci la macchina che vuoi restorare o scrivi fine per terminare lo script, puoi restorare" $a "client: " read CLIENT echo $CLIENT the variable... (1 Reply)
Discussion started by: FrancescoIt
1 Replies

4. Shell Programming and Scripting

How to check on parameters

Hi I have a script that reads a directory name, and then prints all de items in that directory. Now that works, but I want to check on the parameters to be sure that the user has write just 1 parameter, and if not, than the script closes. (7 Replies)
Discussion started by: hss
7 Replies

5. Shell Programming and Scripting

Help with explanation of awk parameters

Hello, Would someone be able to tell me exactly how this command works please? awk '!x++' As usual any help much appreciated (8 Replies)
Discussion started by: Grueben
8 Replies

6. Shell Programming and Scripting

How to check that passed parameters all have the same extension?

$ ls monkey.txt banana.csv tree.txt $ myscript monkey.txt tree.txt All extensions ARE alike. $ myscript *txt All extensions ARE alike. $ myscript monkey.txt banana.csv All extensions are NOT alike. $ myscript * All extensions are NOT alike. My brain has given up; what's the simplest... (11 Replies)
Discussion started by: cs03dmj
11 Replies

7. UNIX for Dummies Questions & Answers

check parameters

Hi, I have a script that takes two parameters. I would check the script to run if these parameters are to null or come with the correct data. If those parameters are to null, display a message, so if they come with two facts that are incorrect. As you might see that? Thx (1 Reply)
Discussion started by: pepeli30
1 Replies

8. Shell Programming and Scripting

passing parameters using awk

Hi, The below script is working fine awk1.sh ======= awk BEGIN { FS="|" } FNR==NR { f1=$2; next } $1 in f1 && $2 =="xx" && $1 == "DAILY_JOB" {print $3} awk -f awk1.sh a.txt b.txt--Its working fine . When passing parameters its not working .Any help it should be appereciated. ... (4 Replies)
Discussion started by: akil
4 Replies

9. UNIX for Dummies Questions & Answers

Parameters to check while differentiating two servers

Hi All, I have two solaris servers. Please tell me what all parameters i can check to find out the difference between two servers. how to differentiate based on H/W,S/W etc like i have two servers spdwa013 $ uname -an SunOS spdwa013 5.8 Generic_117350-61 sun4u sparc SUNW,Sun-Fire-480R ... (1 Reply)
Discussion started by: usha rao
1 Replies

10. Shell Programming and Scripting

AWK alias with parameters

Hello, How can I make an alias of an AWK one liner that prints specific lines from a file like below? # from a command like this: awk 'NR == 100, NR == 150' file.cfg The alias I want to make should work like this(I guess): <alias_command> <file.cfg><start_line><end_line> So the... (1 Reply)
Discussion started by: majormark
1 Replies
Login or Register to Ask a Question