The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Delete trailing white space cillmor Shell Programming and Scripting 5 06-19-2009 09:51 AM
Add white space to the end of a line with sed karlanderson Shell Programming and Scripting 7 03-09-2009 06:20 AM
SED with White Space sandeep_1105 UNIX for Dummies Questions & Answers 1 03-02-2009 04:48 PM
stripping white space... Zak Shell Programming and Scripting 7 10-09-2007 07:41 AM
Sh scripting problem, matching specific white space Dickalicious Shell Programming and Scripting 7 05-24-2006 01:30 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 6 Days Ago
paragkalra paragkalra is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 12
Matching white space through Grep

Hello All,

I am trying to match white space in patterns through - Grep

I tried [[:space:]] & [[:blank:]] but none of them worked.

Then I tried Perl extension '\s' and it worked.

So just wanted to know if [[:space:]] & [[:blank:]] are still supported or have they become deprecated.

However they have been mentioned in the man page so I guess I am not using it correctly. Any pointers on how to use them?
  #2 (permalink)  
Old 6 Days Ago
Scrutinizer Scrutinizer is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 584
They work fine in my grep. What pattern matching are you having trouble with?
  #3 (permalink)  
Old 6 Days Ago
jsmithstl jsmithstl is offline
Registered User
  
 

Join Date: Oct 2009
Location: St. Louis, MO
Posts: 34
This worked for me.

cat myfile
this line has spaces.
this tab
thisnone


grep [[:space:]] myfile

this line has spaces.
this tab
  #4 (permalink)  
Old 6 Days Ago
paragkalra paragkalra is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 12
Ok got it fixed....

# cat /tmp/test.ldif

Quote:
dn: ou=71404558, ou=Company, ou=Personal, o=paragkalra.com
dn: ou=40208723, ou=Company, ou=Personal, o=paragkalra.com
dn: ou=63613012, ou=Company, ou=Personal, o=paragkalra.com
dn: ou=76884580, ou=Company, ou=Personal, o=paragkalra.com

As you can see there is space between 'dn:' and 'ou=' in all the lines

Initially I was placing '\*' after [[:space:]] as shown below:

Quote:
grep -i '^dn:[[:space:]]\*\(ou=[^,]\+,\)\{1\} ou=Company, ou=Personal, o=paragkalra.com' ous.ldif
Then I removed the black slash and it worked:

Quote:
grep -i '^dn:[[:space:]]*\(ou=[^,]\+,\)\{1\} ou=Company, ou=Personal, o=paragkalra.com' ous.ldif
Quote:
dn: ou=71404558, ou=Company, ou=Personal, o=paragkalra.com
dn: ou=40208723, ou=Company, ou=Personal, o=paragkalra.com
dn: ou=63613012, ou=Company, ou=Personal, o=paragkalra.com
dn: ou=76884580, ou=Company, ou=Personal, o=paragkalra.com
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0