Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Linux Programming & Scripting
Reload this Page sed strict pattern
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Linux Programming & Scripting C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Reply
 
Thread Tools Display Modes
Old 07-03-2007   #1 (permalink)
antistes
Just Joined!
 
Join Date: Jul 2007
Posts: 4
sed strict pattern

Hi forum,

i have a small sed script witch strips all special chars from stdin
sed -e "s/[^Aa0-Zz9]/_/g"

My enviroment var LANG is pt_PT.UTF-8 and when i try to strip something like this

echo "Página de teste" | sed -e "s/[^Aa0-Zz9]/_/g"

it outputs 'Página_de_teste' instead of 'P_gina_de_teste' or even better 'Pagina_de_teste'

some help please...
antistes is offline   Reply With Quote
Old 07-03-2007   #2 (permalink)
vsemaska
Linux Newbie
 
Join Date: Jun 2007
Posts: 209
Did you '# export LANG' after setting it?
vsemaska is offline   Reply With Quote
Old 07-03-2007   #3 (permalink)
antistes
Just Joined!
 
Join Date: Jul 2007
Posts: 4
Thats my native lang, i've installed the box (CentOS 4.5) with this lang, and i want to keep it.

The thing is sed thinks that 'á' is included in my search pattern and that's not good.
I just want sed to distinguish one from another.
antistes is offline   Reply With Quote
Old 07-03-2007   #4 (permalink)
Franklin52
Linux Enthusiast
 
Franklin52's Avatar
 
Join Date: Aug 2006
Posts: 596
Try:

Code:
echo "Página de teste" | sed 's/[^A-Z ^a-z ^0-9]/_/g'
Regards
Franklin52 is offline   Reply With Quote
Old 07-03-2007   #5 (permalink)
antistes
Just Joined!
 
Join Date: Jul 2007
Posts: 4
Quote:
Originally Posted by Franklin52 View Post
Try:

Code:
echo "Página de teste" | sed 's/[^A-Z ^a-z ^0-9]/_/g'
Regards
Thanks, but still not working, the output is
'Página de teste'
antistes is offline   Reply With Quote
Old 07-03-2007   #6 (permalink)
Franklin52
Linux Enthusiast
 
Franklin52's Avatar
 
Join Date: Aug 2006
Posts: 596
You can try something like:

Code:
echo "Página de teste" | sed 's/[^A-Z^a-z^0-9]/_/g' | sed 's/á/a/g'
Regards
Franklin52 is offline   Reply With Quote
Old 07-03-2007   #7 (permalink)
antistes
Just Joined!
 
Join Date: Jul 2007
Posts: 4
Cool thats it
it worked fine

just one tiny little problem

i've got to predict all portuguese special chars, and they're quite a bit,
but i can live with that

Thanks
antistes is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Grep | Specifying multiline pattern Stormbr!nger Linux Newbie 1 07-28-2006 02:39 PM
Pattern on screen when sutting dow redcraze Linux Newbie 1 03-09-2005 09:19 AM
Regex help -- pattern exclusion savage_cabbage Linux Programming & Scripting 12 01-27-2005 12:37 PM
pattern matching - plz guide apurv30 Linux Programming & Scripting 2 11-03-2004 02:14 PM
Grep last pattern output lfriend Linux Programming & Scripting 2 09-22-2004 09:50 PM




All times are GMT. The time now is 05:47 AM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.0.0