LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-16-2008, 01:42 AM   #1
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
* option with ls, chown and chmod (suspect more)


I've just noticed this morning that I can't use * wildcard with ls, chown and chmod as user. Works fine as root.

Tried with both bash and sh.

Any ideas what can cause this?

Code:
dive@DarkStar(/str2/ut/Textures) ls *
ls: invalid option -- )
Try `ls --help' for more information.
*Edit: root is affected also.

Last edited by dive; 08-16-2008 at 01:43 AM.
 
Old 08-16-2008, 01:47 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
* is a shell wildcard; the shell expands * to the list of all files (not including dot files, by default). The ls, chown, chmod, etc, utilities never see the *.
 
Old 08-16-2008, 01:59 AM   #3
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Original Poster
Rep: Reputation: Disabled
I'm sure I used to be able to do a 'chmod +w *' in the past. Been a long night...

I can't do a 'mv *.utx ../Temp' for example. Rkhunter doesn't find any problems. Stumped.

Ok it seems that the first filename began with a '-' and this was crapping it out.

Last edited by dive; 08-16-2008 at 02:04 AM.
 
Old 08-16-2008, 02:03 AM   #4
jimX86
Member
 
Registered: Mar 2006
Distribution: Slackware64 -current
Posts: 268
Blog Entries: 1

Rep: Reputation: 79
Is it just in that one directory? One thing that would cause that is a file name that begins with a dash.
 
Old 08-16-2008, 03:45 AM   #5
saulgoode
Member
 
Registered: May 2007
Distribution: Slackware
Posts: 288

Rep: Reputation: 155Reputation: 155
As jimX86 stated, you have a filename in your directory which starts with a hyphen (two hyphens, based on your error message). The wildcard gets expanded to a list of filenames and the ones beginning with hyphens will be interpreted by the command as option switches.

You can disable this switch interpreting (while still expanding wildcards) by including '--' (two hyphens) in your command line (after all the switches actually needed have been specified).

For example:
chmod -v 664 -- --help

would change the mode of a file named "--help". The "-v" is still interpreted as a request for verbose output because it appears before the double-hyphen in the command line. If "-v" appeared after the double-hyphen, it would be considered a filename.

And:
rm -v -- *

would remove all files in the directory, even if one or more of them had a name starting with a hyphen.

Last edited by saulgoode; 08-16-2008 at 03:51 AM.
 
Old 08-16-2008, 04:35 AM   #6
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Original Poster
Rep: Reputation: Disabled
Yes that was the problem. Thanks.
 
  


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
chown and chmod specialized Linux - Hardware 9 04-04-2006 09:26 PM
chmod/chown and folders :) chibi Linux - Newbie 2 04-28-2005 04:56 PM
Chown & Chmod swatward Linux - Newbie 2 03-01-2005 12:57 PM
chmod ,chown ,chgrp------------ pal Linux - Newbie 1 02-27-2005 02:49 PM
Log Chmod and Chown FernandoLozano Linux - Security 5 01-10-2005 09:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:43 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