Help starting a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help starting a script
# 8  
Old 03-02-2012
Quote:
Originally Posted by methyl
Maybe I'm being thick but I repeat:
Please post what the matching output from the 9 lines in the sample input in post #1 should look like.
Like i said the output can be in any format the important is that i can count how many conditions of the 3 that i said there are in the file.

So with awk i was thinking in a output like this:
Code:
TP=0 (the number of $1=1 and $2=1 are in the file)
FP=0 (the number of $1=1 and $2=-1 are in the file)
FN=3 (the number of $1=-1 and $2=1 are in the file)

or can be like 3 files one for the TP other for FP other for FN and i will wc -l the files to get the number of each occurence like this:
Code:
FN File
1
1
1
0
0
0
0
0
0

I ONLY SEE NOW THAT MY LAST POST WAS WRONG REALLY SORRY ABOUT THAT NOW IS CORRECT!!!

In this exemple the only condition that is verified is the one when $1=-1 $2=1 so is a FN, so there are no condition of $1=1 $2=1 that are a TP and there are no condition for $1=-1 $2=1 FP. And the condition $1=-1 $2=-1 i don't need to count.

I'm sorry if this is not to much easy to understand. But the output file doesn't matter because what i need is to know the number of each one of the conditions are.

---------- Post updated at 10:23 AM ---------- Previous update was at 06:01 AM ----------

Quote:
Originally Posted by tip78
Code:
#!/usr/bin/perl -w                                                                                                                    
                                                                                                                                      
@a=qw(0 0 0 0);                                                                                                                       
while(<>){                                                                                                                            
    /^(.+?)\s+(.+?)\s+/;                                                                                                              
    $a[0]++,next if($1 == 1 && $2 == 1);                                                                                              
    $a[1]++,next if($1 == 1 && $2 == -1);                                                                                             
    $a[2]++,next if($1 == -1 && $2 == 1);                                                                                             
    $a[3]++,next if($1 == -1 && $2 == -1);                                                                                            
}                                                                                                                                     
                                                                                                                                      
print"$a[0]     $a[1]   $a[2]   $a[3]\n";

syntax: ./script filename
Well after a lot of trys i just change a bit this script and put it to run with the bash.

Thanks a lot this do exactly what i need Smilie

Last edited by MetaBolic0; 03-02-2012 at 07:15 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to grep a line not starting with # from a file (there are two lines starting with # and normal)?

e.g. File name: File.txt cat File.txt Result: #INBOUND_QUEUE=FAQ1 INBOUND_QUEUE=FAQ2 I want to get the value for one which is not commented out. Thanks, (3 Replies)
Discussion started by: Tanu
3 Replies

2. Shell Programming and Scripting

Script for Starting Firefox?

Presently I have a powershell script (windows only, of course) that enumerates all the instances of "Internet Explorer" running on my machine and if at least one exists, the script creates a new tab in that instance with the URL I have provided. If no instances of Internet Explorer are running, one... (1 Reply)
Discussion started by: siegfried
1 Replies

3. Shell Programming and Scripting

Starting all the components simultaneously through script

Hi Folks , I have the below script that will start the components one by one by giving an interval of few seconds that if first component is started then there is interval of few seconds and then the second component is started , but by this way it takes time, i want to make the process faster... (8 Replies)
Discussion started by: punpun66
8 Replies

4. Shell Programming and Scripting

Help with Temperature Script (Starting

Hello, I am trying to work on a temperature script to check temperatures on my systems. Im trying to get the basics laid out first. So far i have a command: /usr/sbin/prtpicl -v -c temperature-sensor # (must run as root) This command kicks back alot of information but i only want the... (3 Replies)
Discussion started by: whotippedmycow
3 Replies

5. Shell Programming and Scripting

Starting a C++ program from shell script

Hi, I have a little problem...I want to do the following things: Have my own little script that has 2/3 functions and starts a c++ application using some parameters. The problems appear when I start the c++ app using the shell script, the c++ takes over and after I ctrl+c the script... (0 Replies)
Discussion started by: valiadi
0 Replies

6. Shell Programming and Scripting

Starting script without ./ name or sh name

Hi, i want to start my script only by the name of it. $ scriptName normaly i have to use ./scriptName oder sh scriptName is there a way to do that in bash or sh ? (13 Replies)
Discussion started by: Turrican
13 Replies

7. Shell Programming and Scripting

Manage starting point in shell script.

Hi, I'd like to run a script with an optional starting point. Meaning that if no parameter for the script => Do everything, otherwise start from the point specified in the parameter and continue till the end. I thought of using the "case ..." but I have no result. Script: # ---------------... (6 Replies)
Discussion started by: ai_dba
6 Replies

8. UNIX for Dummies Questions & Answers

Problem starting a script from a 'main'-script

Please Help! :o I have a main script (ksh) where another script is called (convert_picture). Normally this works ok, but since some changes has been made on the unix-server (I dont know what :( ) suddenly it doesnt work anymore: i get an error message: ksh: convert_picture not found. I am... (3 Replies)
Discussion started by: Rakker
3 Replies

9. Shell Programming and Scripting

Help starting a simple shell script.

I've been sitting here for 6 hours typing out all kinds of different ridiculous(very pointless) shell scripts for a low-level UNIX class. I'm tired.. and want to go to bed :o Can somebody please help get me on the right path to starting this damn script? i'm useless after all these hours and... (2 Replies)
Discussion started by: dickmartin
2 Replies

10. UNIX for Advanced & Expert Users

Starting a script from a Database procedure

Hey guys, I have this problem : I can run on an sqlprompt !ftp_file2.ksh test.xml 172.16.204.81 Anonymous Anonymous which will ftp the file from Unix to an NT machine, but if I do exec shell('sh ftp_file2.ksh test.xml 172.16.204.81 Anonymous Anonymous') it does NOTHING. I have no... (4 Replies)
Discussion started by: vidireporting
4 Replies
Login or Register to Ask a Question