Regex space character

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Regex space character
# 1  
Old 06-24-2013
Regex space character


I have following regex condition, however it does not work with different logs having same visible string.I believe it is because of some difference with space character, is it possible to make it work everywhere.

Can someone suggest a better string?

/BIND dn=" uid=/

# 2  
Old 06-24-2013
Please post a file that it works on correctly and one that it doesn't.
# 3  
Old 06-24-2013
We cant read your post a sample of the input and desired output along with any code you may have written for input processing...
# 4  
Old 06-24-2013
Here is the log to scan:

[24/Jun/2013:07:21:40 -0600] conn=15570171 op=77 msgId=78 - BIND dn="uid=abc00,ou=people," method=128 version=3

# 5  
Old 06-24-2013
So this is a file that fails. How does one succeeding file look like?
# 6  
Old 06-24-2013
Can you post the code you have to parse BIND dn="uid" string out of the logfiles...
# 7  
Old 06-24-2013
Well, I am using an IF block like this -

if( /BIND dn="uid=/ ) {

                ...some statement..

The issue is when there are some space before "uid" string, here are two examples :

# no space before uid.
[24/Jun/2013:07:21:40 -0600] conn=15570171 op=77 msgId=78 - BIND dn="uid=abc00,ou=people," method=128 version=3

# space before uid.
[24/Jun/2013:07:21:40 -0600] conn=15570171 op=77 msgId=78 - BIND dn=" uid=abc00,ou=people," method=128 version=3

I would like my regex to take care of space as well.

I tried something like this, but it does not work.

BIND dn=\s"uid=


Last edited by susankoperna1; 06-24-2013 at 07:27 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regex issue with \s in character class.

Anybody have an explanation for why \s doesn't match ' ' in a character class? Here are 3 examples with the final example showing that \s in a character class (demonstrated by using egrep -o) fails: \s works outside of class.. # echo " FOO " | egrep -o '\s+\s' FOO Here is a... (6 Replies)
Discussion started by: blackrageous
6 Replies

2. Shell Programming and Scripting

Read character by character in line in which space is also included

Hi friend, I have one file , and i want to read that file character by character. I need this script in ksh. while using read option with -n1 am getting error. while read -n1 c read has bad option And if i am using below script, then if in a line has space like this ( Pallvi mahajan)... (10 Replies)
Discussion started by: pallvi_mahajan
10 Replies

3. Shell Programming and Scripting

Regex:search/replace but not for escaped character

Hi Input: - -- --- ---- aa-bb-cc aa--bb--cc aa---bb---cc aa----bb----cc Output: . - -. -- (7 Replies)
Discussion started by: chitech
7 Replies

4. Shell Programming and Scripting

Regex escape special character in AWK if statement

I am having issues escaping special characters in my AWK script as follows: for id in `cat file` do grep $id in file2 | awk '\ BEGIN {var=""} \ { if ( /stringwith+'|'+'50'chars/ ) { echo "do this" } else if ( /anotherString/ ) { echo "do that" } else { ... (4 Replies)
Discussion started by: purebc
4 Replies

5. UNIX for Dummies Questions & Answers

Adding space after character using sed?

dears i have the data below, i want a command ( i think it should be sed) that add a space after the seconds as below : Jun 24 22:28:18966568406148@ Jun 24 05:47:35966555747744@ Jun 24 05:47:53966560825239@ Jun 24 06:07:52966541147164@ Jun 24 15:49:55966566478883@ thanks... (5 Replies)
Discussion started by: thehero
5 Replies

6. Shell Programming and Scripting

Remove space before a character

Hi guys, I am new to shell scripting and I have a small problem...If someone can solve this..that would be great I am trying to form a XML by reading a flat file using shell scripting This is my shell script LINE_FILE1=`cat FLEX_FILE1.TXT | head -1 | tail -1` echo... (1 Reply)
Discussion started by: gowrishankar05
1 Replies

7. UNIX for Dummies Questions & Answers

blank space in regex pattern using sed

why does sed 's/.* //' show the last word in a line and sed 's/ .*//' show the first word in a line? How is that blank space before or after the ".*" being interpreted in the regex? i would think the first example would delete the first word and the next example would delete the second... (1 Reply)
Discussion started by: glev2005
1 Replies

8. UNIX for Dummies Questions & Answers

sed with variable containing space character

Hi all, I have the following script S1a="13 9 -0.0012041" S1b="13 8 -1.00000 " sed 's/${S1b}/${S1a}/g' funE00.i > tmp1 but the strings are not replaced. Maybe the problem is in the spaces cointaned in the variables? Thanks for your help, Sarah (2 Replies)
Discussion started by: f_o_555
2 Replies

9. Shell Programming and Scripting

Regex/sed - matching any char,space,underscore between : and /

trying to remove the portion in red: Data: mds_ar/bin/uedw92wp.ksh: $AI_SQL/wkly.sql mds_ar/bin/uedw92wp.ksh: $EDW_TMP/wkly.sql output to be: mds_ar/bin/uedw92wp.ksh: wkly.sql mds_ar/bin/uedw92wp.ksh: wkly.sql SED i'm trying to use: sed 's/:+\//: /g' input_file.dat >... (11 Replies)
Discussion started by: danmauer
11 Replies

10. AIX

How can i replace a character with blank space?

i want a command for my script!!! say file consists of character 123 125 127. i need a query to replace the number 2 with 0 so the output should be 103 105 107. i use unix-aix (8 Replies)
Discussion started by: rollthecoin
8 Replies
Login or Register to Ask a Question

Featured Tech Videos