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
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.
$ 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**
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.)
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
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
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-)
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 "\nEnter new name for inode ${j}" echo -n "${wasname}"" : " read newname echo -ne "\nrename ${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