LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 08: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 ?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-14-2007, 09:05 PM   #2
{BBI}Nexus{BBI}
Senior Member
 
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 6, KDE Neon
Posts: 4,313

Rep: Reputation: 212Reputation: 212Reputation: 212
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, 09:07 PM   #3
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Any chance there's a file name starting with a dash containing an 'e'? Try "ls -- *txt*".
 
2 members found this post helpful.
Old 02-14-2007, 09: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, 09:25 PM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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.
 
1 members found this post helpful.
Old 02-15-2007, 07: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, 02:04 PM   #7
Lunar
Member
 
Registered: Feb 2005
Location: Texas, USA
Distribution: opensuse
Posts: 106
Blog Entries: 1

Rep: Reputation: 8
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, 08:16 PM   #8
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
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 08:21 PM.
 
Old 12-21-2016, 10:20 AM   #9
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
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



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 01:49 PM
dkmraid -i invalid option sang_froid Linux - General 0 10-16-2006 08:50 AM
cp indicates invalid option Murdock1979 Linux - Software 1 01-24-2006 02: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 02:47 AM
in.telnetd: invalid option -- L implant23 Linux - Networking 1 12-01-2002 11:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:25 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
Open Source Consulting | Domain Registration