LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-21-2008, 11:48 PM   #1
livetoday
Member
 
Registered: Jun 2006
Location: India
Distribution: RHEL,Suse,Fedora
Posts: 106

Rep: Reputation: 15
Bash Scripting POSIX Class [[:alnum:]] giving wrong output


Hi all,

I am using GNU bash, version 3.00.15(1)-release on Fedora 4. I am trying to learn the use of POSIX Classes in Bash Scripting. But I got stuck at one point while using [[:alnum:]] class.

cat file1

sunil kumar
25
class B
SUNIL
2008


now while I run the command " grep [[:alnum:]] file1 " (without quotes)

I get the output as

25
2008

while I think it should give numbers as well alphabets in the output. Kindly let me know what I am doing wrong....

Other POSIX classes i.e. [[:alpha:]],[[:digit:]] are working fine.

Below is the URL I am referring to..


http://tldp.org/LDP/abs/html/x15576.html
 
Old 01-22-2008, 12:19 AM   #2
moniker117
Member
 
Registered: May 2005
Location: Los Angeles, CA, USA
Distribution: Arch
Posts: 48

Rep: Reputation: 15
When I follow the example you described I get:

sunil kumar
25
class B
SUNIL
2008

I wonder if it's a bug in the version of bash that you're running. Can you update it? I'm running the bash that comes with Fedora 8. bash --version yields:
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
 
Old 01-22-2008, 12:41 AM   #3
livetoday
Member
 
Registered: Jun 2006
Location: India
Distribution: RHEL,Suse,Fedora
Posts: 106

Original Poster
Rep: Reputation: 15
Thanks moniker117 for this quick reply........I tried it in ksh and it is working perfectly....


Quote:
Originally Posted by moniker117 View Post
When I follow the example you described I get:

sunil kumar
25
class B
SUNIL
2008

I wonder if it's a bug in the version of bash that you're running. Can you update it? I'm running the bash that comes with Fedora 8. bash --version yields:
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
 
Old 01-22-2008, 12:56 AM   #4
moniker117
Member
 
Registered: May 2005
Location: Los Angeles, CA, USA
Distribution: Arch
Posts: 48

Rep: Reputation: 15
I guess it is some sort of bug in bash. I'm glad you were able to figure it out.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
uname giving wrong info ddu_ Linux - Newbie 2 06-14-2007 10:05 PM
Wrong parsing of ls command in bash scripting itz2000 Programming 3 04-25-2007 11:23 AM
Audigy 2 ZS not giving any output khaledaboualfa Ubuntu 1 07-19-2006 06:56 PM
bash simple test with posix character class osio Programming 5 01-22-2006 08:23 PM
df -h is giving weird output chens_83 Linux - General 2 12-09-2002 12:32 PM


All times are GMT -5. The time now is 02:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration