Register
It is currently Fri Aug 01, 2014 5:50 am

HELP: grep exclude pattern


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Sep 24, 2010 8:47 am   

Joined: Mon Sep 20, 2010 7:56 pm
Posts: 6
Heylo guys,
i have a noob question
does anyone know how to exclude a certain pattern in a range in grep?
ex: exclude "A" "C" "E" from [[:upper:]]

thx!!!


Top
 Profile  
 PostPosted: Mon Sep 27, 2010 5:08 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
[:upper:] is the same as A-Z so what it seems you're after is [BDF-Z], however there is some weirdness with locales that means this does not quite work (check the grep man page for more info on that) so you may need to change an environment variable to ensure correct case sensitivity...

Code:
export LC_ALL=C
~]# echo "A" | grep '[BDF-Z]'
~]# echo "p" | grep '[BDF-Z]'
~]# echo "P" | grep '[BDF-Z]'
P


I hope this helps :)

DW


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP