LinuxQuestions.org
Review your favorite Linux distribution.
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 02-14-2007, 09:30 PM   #1
MrMark
LQ Newbie
 
Registered: Jan 2007
Posts: 9

Rep: Reputation: 0
ls *txt* returns invalid option --e Eh ???


G'day

Linux newbie ive got a whole heap of files that end in .txt and I want to get a list of all files in my current directory that have txt in them, so I figured ls *txt* would work, but it doesn't it returns invalid option -- e. I've also tried ls *.txt ls *txt, and ls *t*, all return invalid option e. However, if i try ls *bash*, it works fine. I'm using the bash shell. So to me that tells me im using the right syntax...but then why wouldn't it work with .txt ?
 
Old 02-14-2007, 10:05 PM   #2
{BBI}Nexus{BBI}
Senior Member
 
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 5, Linux Lite
Posts: 4,312

Rep: Reputation: 209Reputation: 209Reputation: 209
Try this: locate /home/[type directory name here]/*.txt

There may be a better way, but this way works for me.
 
Old 02-14-2007, 10:07 PM   #3
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 123Reputation: 123
Any chance there's a file name starting with a dash containing an 'e'? Try "ls -- *txt*".
 
1 members found this post helpful.
Old 02-14-2007, 10:21 PM   #4
MrMark
LQ Newbie
 
Registered: Jan 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Matir
Any chance there's a file name starting with a dash containing an 'e'? Try "ls -- *txt*".
yup there was and that did the trick. Why cant ls handle files beginning with a dash ?
 
Old 02-14-2007, 10:25 PM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 123Reputation: 123
Quote:
Originally Posted by MrMark
yup there was and that did the trick. Why cant ls handle files beginning with a dash ?
It can't tell the difference between "ls -option" and "ls -filename". The - is used to indicate the start of options. "--" disables option processing.
 
Old 02-15-2007, 08:57 PM   #6
MrMark
LQ Newbie
 
Registered: Jan 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
It can't tell the difference between "ls -option" and "ls -filename". The - is used to indicate the start of options. "--" disables option processing.
Ah, that makes sense now. Intresting little gotcha.

Thanks for your help mate
 
Old 12-20-2016, 03:04 PM   #7
Lunar
Member
 
Registered: Feb 2005
Location: Texas, USA
Distribution: opensuse
Posts: 96

Rep: Reputation: 3
No Sh* - Thanks

Quote:
Originally Posted by Matir View Post
Any chance there's a file name starting with a dash containing an 'e'? Try "ls -- *txt*".
I've Never seen this before. I've used -FileName (hyphen FileName) for years to get a info or important file to list first... Wow.

I was exhausted. My next step was to compile utils from source.

In My Case: I had a file named '-2016.11.26-whatever.txt' - it was important info from that date. I didn't connect the --'2' error with file names and was getting:
Code:
ls *.txt
ls: invalid option -- '2'
P.S. - weird thing is, I didn't get the error in terminal as root, working on same directory / files using same options ls *.txt
Only difference is for root:
# echo $LS_OPTIONS there is a '-A' where my user does not have the '-A' - rest is the same

THANK YOU!
Landis.
 
Old 12-20-2016, 09:16 PM   #8
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 314

Rep: Reputation: 123Reputation: 123
Just for fun, you can create a file named --help

(and when that gets tiresome, delete it by rm ./--help )

Last edited by Beryllos; 12-20-2016 at 09:21 PM.
 
Old 12-21-2016, 11:20 AM   #9
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 7,680
Blog Entries: 10

Rep: Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080
Landis:
You can use
Code:
type
utility to see if and/or how it's been modified from 'expected' behaviors in user or root,
Code:
$ type ls
sudo su -
# type ls
I disable them interactively by preceding with \<alias>
or
unalias <alias>

Have fun.
 
  


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
shmget returns invalid segment size specified BobS0327 Programming 1 11-08-2006 02:49 PM
dkmraid -i invalid option sang_froid Linux - General 0 10-16-2006 09:50 AM
cp indicates invalid option Murdock1979 Linux - Software 1 01-24-2006 03:21 AM
can mount C not D FAT: invalid media value (0x45) mount: wrong fs type, bad option Emmanuel_uk Linux - Newbie 10 11-29-2005 03:47 AM
in.telnetd: invalid option -- L implant23 Linux - Networking 1 12-01-2002 12:17 PM


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