LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-25-2009, 05:01 AM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Shell glob element [:space:] not working as expected


Hello

The following terminal transcript shows [:space:] not matching a space character as expected. Why not?
Code:
c@CW8:~$ touch 'a b'
c@CW8:~$ ls -l a[:space:]b
ls: cannot access a[:space:]b: No such file or directory
c@CW8:~$ ls -l a*b
-rw-r--r-- 1 c c 0 2009-07-25 15:19 a b
c@CW8:~$ shopt extglob
extglob        	on
c@CW8:~$ locale
LANG=en_IN
LC_CTYPE="en_IN"
LC_NUMERIC="en_IN"
LC_TIME="en_IN"
LC_COLLATE="en_IN"
LC_MONETARY="en_IN"
LC_MESSAGES="en_IN"
LC_PAPER="en_IN"
LC_NAME="en_IN"
LC_ADDRESS="en_IN"
LC_TELEPHONE="en_IN"
LC_MEASUREMENT="en_IN"
LC_IDENTIFICATION="en_IN"
LC_ALL=
c@CW8:~$ echo $SHELL
/bin/bash
c@CW8:~$ /bin/bash --version
GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
Best

Charles
 
Old 07-25-2009, 05:14 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
I have always used it with double square brackets, that is a range of characters, where the characters are those given by [:space:]. It works for me:
Code:
$ touch 'a b'
$ ls -l a[[:space:]]b
-rw-r--r-- 1 colucix users 0 Jul 25 12:09 a b
$ shopt extglob
extglob         off
$ bash --version
GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
 
Old 07-25-2009, 06:11 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Hello colucix
Quote:
Originally Posted by colucix View Post
I have always used it with double square brackets, that is a range of characters, where the characters are those given by [:space:]
Thanks, that does it!

So where the GNU bash reference says Within ‘[’ and ‘]’, character classes can be specified using the syntax [:class:], where class is one of the following classes defined in the posix standard: alnum, alpha, ascii, blank ... it means [:blank:] within [] giving [[:blank:]. Good to know.

Best

Charles
 
  


Reply



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
LXer: pv (Pipe Viewer) - Shell pipeline element to meter data passing through LXer Syndicated Linux News 0 12-28-2008 09:20 PM
help with glob - perl invoked from shell johngreg Programming 16 11-12-2008 03:33 PM
find not working as expected luusac Linux - Newbie 8 08-28-2008 11:07 AM
alias not working as expected marozsas Linux - General 3 06-01-2006 12:46 PM
Useradd - not working as expected Paean Solaris / OpenSolaris 13 01-31-2006 04:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:57 AM.

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
Open Source Consulting | Domain Registration