LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-15-2009, 08:35 AM   #1
Virchanza
LQ Newbie
 
Registered: Aug 2009
Posts: 26

Rep: Reputation: Disabled
How to tell "ls" not to enter subdirectories


Under Microsoft Windows, if I want to see all of the txt files in a folder, I just do:

dir *.txt

However, under Linux, if I do:

ls *.txt

Then it searches in subdirectories as well and I don't want it to do that.

Anybody know the solution?
 
Old 10-15-2009, 09:04 AM   #2
amani
Senior Member
 
Registered: Jul 2006
Location: Kolkata, India
Distribution: Debian 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,766

Rep: Reputation: Disabled
Your shell has been modified with alias

Change it

#man ls
 
Old 10-15-2009, 10:44 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
As amani suggested that is very strange behaviour unless you have directories named <something>.txt.

You can check for aliases (ls is often aliased) using the alias command or you can ensure you do not use an alias by using /bin/ls or \ls. The first fully specifies which ls executable to use and the second says "ignore any aliases".

The option to tell ls to list any directories in the list of names you give it (as opposed to the contents of such directories) is -d. Thus ls -d *.txt may do what you want.
 
Old 10-15-2009, 12:23 PM   #4
Virchanza
LQ Newbie
 
Registered: Aug 2009
Posts: 26

Original Poster
Rep: Reputation: Disabled
I ran "alias" and it gave me:

Code:
alias ls='ls --color=auto --human-readable'
Anyway I think I worded my question wrong. The problem I had was that instead of just showing me directory names, it would print the entire contents of the directories.

Your solution of using "-d" works fine, thanks!
 
Old 10-15-2009, 12:48 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by Virchanza View Post
Your solution of using "-d" works fine, thanks!
Glad you found out how to do what you wanted Please mark the thread SOLVED via "Thread Tools"->"Mark this thread as solved".

That alias you showed is pretty innocuous
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Enter Key" not working, how to map "Enter Key" functionality to "F9" Key srinihi Linux - Newbie 1 04-03-2009 02:46 PM
Apache2 > "order allow,deny" to allow subdirectories cbonar Linux - Server 13 10-27-2007 03:08 PM
Command "find" misses some subdirectories vallond Linux - Enterprise 0 07-19-2007 04:55 AM
About SElinux: enter "setenforce 0",system complains bad command aladin Linux - Software 3 08-21-2005 08:16 PM
"Disk boot failure. Enter system disk and press enter" Fear58 Linux - Hardware 3 06-25-2004 05:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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