FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 10-24-2010, 09:39 AM
Niki Kovacs
 
Default Maybe OT : strange wildcard behaviour

Hi,

I'm currently working through some basic HOWTOS (Linux Fundamentals 1-4
by Gentoo founder Daniel Robbins) on a CentOS 5.5 server, just to keep
in shape.

I've just noticed a curious wildcard behaviour, which I can't really
explain. Let's say I wanted to list all the files or directories in /tmp
starting with any uppercase character. Normally, I would do this :

$ ls -d /tmp/[A-Z]*

Curiously enough, this command lists *all* the content of /tmp,
consisting of a majority of files and directories starting with a
*lowercase* character. I've tested this on two different machines, with
the same results. I'm puzzled.

Can anybody offer an explanation for this curious behaviour ?

Cheers,

Niki

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-24-2010, 11:53 AM
Nicolas Thierry-Mieg
 
Default Maybe OT : strange wildcard behaviour

Niki Kovacs wrote:
> Hi,
>
> I'm currently working through some basic HOWTOS (Linux Fundamentals 1-4
> by Gentoo founder Daniel Robbins) on a CentOS 5.5 server, just to keep
> in shape.
>
> I've just noticed a curious wildcard behaviour, which I can't really
> explain. Let's say I wanted to list all the files or directories in /tmp
> starting with any uppercase character. Normally, I would do this :
>
> $ ls -d /tmp/[A-Z]*
>
> Curiously enough, this command lists *all* the content of /tmp,
> consisting of a majority of files and directories starting with a
> *lowercase* character. I've tested this on two different machines, with
> the same results. I'm puzzled.
>
> Can anybody offer an explanation for this curious behaviour ?

probably "expected" behavior, depending on your locale.
google for LC_COLLATE.

LC_COLLATE='C' ; ls -d /tmp/[A-Z]*
should do what you want.
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-24-2010, 07:52 PM
Gordon Messmer
 
Default Maybe OT : strange wildcard behaviour

On 10/24/2010 04:53 AM, Nicolas Thierry-Mieg wrote:
> probably "expected" behavior, depending on your locale.
> google for LC_COLLATE.

And you can read more in 'man 7 locale'.
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-25-2010, 05:08 PM
"Brunner, Brian T."
 
Default Maybe OT : strange wildcard behaviour

>
> $ ls -d /tmp/[A-Z]*

Works as expected here.

> Can anybody offer an explanation for this curious behaviour ?
Try:
alias ls (to see if you're getting invisible flags enabled)
/bin/ls -d /tmp/[A-Z]* (to try the command without such)
************************************************** *****************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error please
notify the system manager. This footnote also confirms that this
email message has been swept for the presence of computer viruses.
www.Hubbell.com - Hubbell Incorporated**

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-25-2010, 08:38 PM
ken
 
Default Maybe OT : strange wildcard behaviour

I'm getting strange stuff too:

$ /bin/ls -l radiolab101510--Fate-and-Fortune.mp3
-rw-r--r-- 1 zl zl 57144527 Sep 30 16:10
radiolab101510--Fate-and-Fortune.mp3
$ /bin/ls -l *.mp3
/bin/ls: unrecognized option `--Fate-and-Fortune.mp3'
Try `/bin/ls --help' for more information.
$ rpm -qf /bin/ls
coreutils-5.97-23.el5_4.2

(Output of the first command was wrapped by my mailer.)
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-25-2010, 08:42 PM
Stephen Harris
 
Default Maybe OT : strange wildcard behaviour

On Mon, Oct 25, 2010 at 04:38:15PM -0400, ken wrote:
> I'm getting strange stuff too:
>
> $ /bin/ls -l radiolab101510--Fate-and-Fortune.mp3
> -rw-r--r-- 1 zl zl 57144527 Sep 30 16:10
> radiolab101510--Fate-and-Fortune.mp3
> $ /bin/ls -l *.mp3
> /bin/ls: unrecognized option `--Fate-and-Fortune.mp3'

You have a file begining with a - sign and this is expanding on
the comamnd line.


Do "ls -l -- *.mp3" to be safe

--

rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-25-2010, 08:51 PM
 
Default Maybe OT : strange wildcard behaviour

ken wrote:
> I'm getting strange stuff too:
>
> $ /bin/ls -l radiolab101510--Fate-and-Fortune.mp3
> -rw-r--r-- 1 zl zl 57144527 Sep 30 16:10
> radiolab101510--Fate-and-Fortune.mp3
> $ /bin/ls -l *.mp3
> /bin/ls: unrecognized option `--Fate-and-Fortune.mp3'
> Try `/bin/ls --help' for more information.
> $ rpm -qf /bin/ls
> coreutils-5.97-23.el5_4.2
>
> (Output of the first command was wrapped by my mailer.)

Try wrapping the filename in single quotes, so that it's not interpreted
by the shell as a flag or option.

mark

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-26-2010, 12:37 AM
Gordon Messmer
 
Default Maybe OT : strange wildcard behaviour

On 10/25/2010 01:51 PM, m.roth@5-cent.us wrote:
> Try wrapping the filename in single quotes, so that it's not interpreted
> by the shell as a flag or option.

Wrapping a filename in quotes doesn't prevent it from being interpreted
as a flag or option.
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-26-2010, 12:39 AM
Gary Greene
 
Default Maybe OT : strange wildcard behaviour

On 25/10/10 5:37 PM, "Gordon Messmer" <yinyang@eburg.com> wrote:
> On 10/25/2010 01:51 PM, m.roth@5-cent.us wrote:
>> Try wrapping the filename in single quotes, so that it's not interpreted
>> by the shell as a flag or option.
>
> Wrapping a filename in quotes doesn't prevent it from being interpreted
> as a flag or option.
> _______________________________________________
> CentOS mailing list
> CentOS@centos.org
> http://lists.centos.org/mailman/listinfo/centos

If the app supports it (most good GNU like apps do) you need the double dash
option which will end option processing (ls -l -- -my_stupid_file.foo-)

--
Gary L. Greene, Jr.
IT Operations
Minerva Networks, Inc.
Cell: (650) 704-6633
Office: (408) 240-1239


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-26-2010, 02:12 AM
 
Default Maybe OT : strange wildcard behaviour

> If the app supports it (most good GNU like apps do) you need the double dash
> option which will end option processing (ls -l -- -my_stupid_file.foo-)

A script to rename files with unhelpful names:


#! /bin/bash
# Rename files by choosing from a menu C. Polisher 2003/04/21
ls -i
echo -n "Enter inode of file to rename: "
read j
wasname=`find . -maxdepth 1 -inum "${j}" -printf "%p"`
wasname=`echo "${wasname}"|cat -vET`
echo -ne "
Enter new name for inode ${j}"
echo -n "${wasname}"" : "
read newname
echo -ne "
rename ${wasname} to ${newname} (y or n)? "
read yorn
while true
do
case "${yorn}" in
Y|y|yes|YES|Yes|yES)
find . -maxdepth 1 -inum "${j}" -exec mv {} "${newname}" ;
break
;;
*)
break
;;
esac
done


--
Charles Polisher

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 01:12 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org