Help with awk array syntax & counting script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with awk array syntax & counting script
# 1  
Old 01-23-2012
ignore

.....

Last edited by elbee11; 01-24-2012 at 07:12 PM..
# 2  
Old 01-23-2012
elseif is not a keyword in awk, it's just being treated as a variable name

try using this:
Code:
if (CRESP==1 && RESP==1) hit++;
if (CRESP==1 && RESP==2) miss++;
if (CRESP==2 && RESP==1) falsealarm++;
if (CRESP==2 && RESP==2) corrrej++;

This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 01-23-2012
oh, that worked to get the numbers right! thanks!

unfortunately though when it's with the rest of my script it still gives the error Unmatched '. --- i don't get why it works by itself, and the first part of the script works by itself, but when I add in awk it doesn't work anymore?
# 4  
Old 01-23-2012
Can't help much without seeing the script.

Try putting #!/bin/bash -x on the 1st line. -x will echo each command as it's run and may help find the line causing the issue.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Isolating & Counting IP from log file

Dear Community, today my website was under attack for several hours. 2 specific IPs make a tons of "get requests" to a specific page and apache server goes up and down. Now the problem is solved because I put in firewall blacklist these IPs, but I took a lot of time to analyze the apache log to... (6 Replies)
Discussion started by: Lord Spectre
6 Replies

2. Shell Programming and Scripting

Shell script with awk command for counting in a file

Hi, I hope you can help me with the awk command in shell scripting. I want to do the following, but it doesn't work. for i in $REF1 $REF2 $REF3; do awk '{if($n>=0 && $n<=50000){count+=1}} END{print count}' ${DIR}${i} >${DIR}${i}_count.txt done REF1 to REF3 are only variables for .txt... (1 Reply)
Discussion started by: y.g.
1 Replies

3. Shell Programming and Scripting

Help with awk script (syntax error in regular expression)

I've found this script which seems very promising to solve my issue: To search and replace many different database passwords in many different (.php, .pl, .cgi, etc.) files across my filesystem. The passwords may or may not be contained within quotes, single quotes, etc. #!/bin/bash... (4 Replies)
Discussion started by: spacegoose
4 Replies

4. UNIX for Dummies Questions & Answers

awk: syntax for "if (array doesn't contain a particular index)"

Hi! Let's say I would like to convert "1", "2", "3" to "a", "b", "c" respectively. But if a record contains other number then return "X". input: 1 2 3 4 output: a b c X What is the syntax for: if(array doesn't contain a particular index){ then print the value "X" instead} (12 Replies)
Discussion started by: beca123456
12 Replies

5. Shell Programming and Scripting

sed&awk: replace lines with counting numbers

Dear board, (I am trying to post this the 3rd time, seems there's some conflicts with my firefox with this forum, now use IE) ------ yes, I have searched the forum, but seems my ? is too complicated. ------------origianl file --------------- \storage\qweq\ertert\ertert\3452\&234\test.rec... (4 Replies)
Discussion started by: oUo
4 Replies

6. Shell Programming and Scripting

[AWK script]Counting the character in record and print them in condition

.......... (1 Reply)
Discussion started by: Antonlee
1 Replies

7. Shell Programming and Scripting

AWK syntax /bailing script error when executing in UNIX

Hi I am trying to execute the following awk script in unix but getting the following error awk: syntax error near line 1 awk: bailing out near line 1 for i in `cat search` do grep -i -l $i *.sas | awk -v token=$i '{print token "\t" $0}' done Please let me know what could be the... (4 Replies)
Discussion started by: nandugo1
4 Replies

8. Shell Programming and Scripting

Awk Script Counting of Correct vs. Error Responses

Hello, I have been trying to use an awk script to parse out correct and incorrect answers in a simple tab-delimited text file. I am trying to compare the user's response to the stimulus presented (in this case, an arrow pointing left or right; e.g., "<--" vs. "-->"). I have the data for the... (6 Replies)
Discussion started by: Jahn
6 Replies

9. UNIX for Dummies Questions & Answers

syntax for counting & printing record count

Hi I have a complex script which outputs a text file for loading into a db. I now need to enhance this script do that I can issue an ‘lp' command to show the count of the number of records in this file. Can anybody give me the necessary syntax ? (2 Replies)
Discussion started by: malts18
2 Replies

10. Shell Programming and Scripting

OR operator syntax question in AWK script

Hi guys, I confused about syntax used in OR script as follow: I have this sample file separated by "|" containing: January|Month No. 1 February|Month No. 2 March|Month No. 3 April|Month No. 4 May|Month No. 5 June|Month No. 6 July|Month No. 7 August|Month No. 8 September|Month No. 9... (11 Replies)
Discussion started by: cgkmal
11 Replies
Login or Register to Ask a Question