Pattern-Matching in If-Condition


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pattern-Matching in If-Condition
# 1  
Old 12-20-2005
Pattern-Matching in If-Condition

Hey Guys,

I'm fighting with a particular pattern match today (ksh)... I need your help!

Middle in my script I read a variable A's value. This value could have three differents form:
1) the NumClicks is the number of clicks user makes during session.
2) the MeanRate is the average number of seconds between each click
3) the SDRate is the standard deviation (n-1) of the seconds between each click (my theory is individual sessions might have evenly spaced clicks -> smaller standard deviations than other sessions).

Some other variable must be read only if variable A is "x". For that I choose a if-condition without success:

Code:
if [ $A = "x" ] or if [ $A = "x" ]
if [ $A = "x" ] or if [ $A = "x" ]

My goal is to try and see if I can find un-discovered sessions by comparing file "x" to file "y" and creating new rules/conditions to find better patterns. Keep in mind my data files are too large to grok by merely looking at them; therefore, i'm using some nice commands to cut out some columns and sort stuff out. Thanks in advance guys Smilie
# 2  
Old 12-20-2005
not sure what you're asking here, but....
Code:
#!/bin/ksh

typeset -i a=5
typeset -i b=15

if (( a == 5 || b == 10 )); then
   echo 'match'
else
   echo 'no match'
fi

# 3  
Old 12-20-2005
Quote:
Originally Posted by vgersh99
not sure what you're asking here, but....
Code:
#!/bin/ksh

typeset -i a=5
typeset -i b=15

if (( a == 5 || b == 10 )); then
   echo 'match'
else
   echo 'no match'
fi

Thanks vgersh99,

Perhaps I can be more specific here. I am trying to distinguish "robot" sessions from "real user" sessions via raw access logs. After cleaning up the logs I assign an ID to each session. I then sort the rows in the log files to group all the rows for the same session together, and assign a session sequence number to each row. The results is a sequenced type url file. This file is the input to my robot detection routine, along with a few other downstream processes. Ultimately I am trying to see if I can find ANY undiscovered robot sessions from the output of these files...hence I feel pattern matching is the best fit for me here.
# 4  
Old 12-20-2005
ok. and the question is..... ?
# 5  
Old 12-20-2005
Quote:
Originally Posted by vgersh99
ok. and the question is..... ?
Do you think I have have sufficient data above to find unique patterns between bots and users or have I missed something? If so, do you have any ideas for additional rules and/or conditions? Thanks
# 6  
Old 12-20-2005
to be honest with you..... I have no idea what the definitions for 'bots' and 'users' are - this is all too application specific. If you have sample data files/records you would be the best person to identify the consistent patterns based on your knowledge of what you're doing and the objective.

Once you do that it becomes "a simple matter of implementation".
# 7  
Old 12-20-2005
Quote:
Originally Posted by vgersh99
to be honest with you..... I have no idea what the definitions for 'bots' and 'users' are - this is all too application specific. If you have sample data files/records you would be the best person to identify the consistent patterns based on your knowledge of what you're doing and the objective.

Once you do that it becomes "a simple matter of implementation".
thank you for your time Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Grep -v lines starting with pattern 1 and not matching pattern 2

Hi all! Thanks for taking the time to view this! I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern. Example: Drink a soda Eat a banana Eat multiple bananas Drink an apple juice Eat an apple Eat multiple apples I... (8 Replies)
Discussion started by: demmel
8 Replies

2. Shell Programming and Scripting

PHP - Regex for matching string containing pattern but without pattern itself

The sample file: dept1: user1,user2,user3 dept2: user4,user5,user6 dept3: user7,user8,user9 I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Discussion started by: urello
8 Replies

3. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

4. UNIX for Dummies Questions & Answers

Find pattern suffix matching pattern

Hi, I am trying to get a result out of this but fails please help. Have two files /tmp/1 & /tmp/hosts. /tmp/1 IP=123.456.789.01 WAS_HOSTNAME=abcdefgh.was.tb.dsdc /tmp/hosts 123.456.789.01 I want this result in /tmp/hosts if hostname is already there dont want duplicate entry. ... (5 Replies)
Discussion started by: rajeshwebspere
5 Replies

5. Shell Programming and Scripting

If condition matching with special chars

Hi, I have file #cat drivers.txt fcs0 fcs1 vscsi1 vscsi2 In this i need to check the availabality of "fcs" or "vscsi" alone not vscsi0,fcs1 I tried with "if condition" but it is not working. cat drivers.txt| while read ADAP do echo "Checking for $ADAP" if ;then echo "FC... (9 Replies)
Discussion started by: ksgnathan
9 Replies

6. Shell Programming and Scripting

multiple condition matching and doing some predefined work

Hi everybody, I had 10 files in in one folder(/home/sai/) namely sai. 1.gz,2.gz,3.gz ..,10.gz. I want to delete the files which are there home based on the following conditions fliecount in sai folder==10 && grep -cv ".gz"==0 How to check this using awk? Otherwise please... (2 Replies)
Discussion started by: p_sai_ias
2 Replies

7. Shell Programming and Scripting

matching patterns inside a condition in awk

I have the following in an awk script. I want to do them on condition that: fext == "xt" FNR == NR { />/ && idx = ++i $2 || val = $1 next } FNR in idx { v = val] } { !/>/ && srdist = abs($1 - v) } />/ || NF == 2 && srdist < dsrmx {... (1 Reply)
Discussion started by: kristinu
1 Replies

8. UNIX for Dummies Questions & Answers

csh, pattern matching in if() condition.

Hi: I am struggling to get the simplest pattern matching to work, in csh. In this line: if ("$MY" =~ /my/) echo match it seems that I just can not make it to match, even when $MY is "mymymy". Thanks. N.B Phil ---------- Post updated at 11:23 PM ---------- Previous update... (0 Replies)
Discussion started by: phil518
0 Replies

9. Shell Programming and Scripting

counting the lines matching a pattern, in between two pattern, and generate a tab

Hi all, I'm looking for some help. I have a file (very long) that is organized like below: >Cluster 0 0 283nt, >01_FRYJ6ZM12HMXZS... at +/99% 1 279nt, >01_FRYJ6ZM12HN12A... at +/99% 2 281nt, >01_FRYJ6ZM12HM4TS... at +/99% 3 283nt, >01_FRYJ6ZM12HM946... at +/99% 4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies

10. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies
Login or Register to Ask a Question