LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-13-2009, 12:45 PM   #1
Canis Polaris
LQ Newbie
 
Registered: May 2007
Posts: 15

Rep: Reputation: 0
How to Limit "ls -la a*" to Current Directory


When I execute a list directory contents command (ls) with a filename filter, such as:

$ ls -la s*

the system returns all of the files that start with "s", which is what I want, but it also returns all of the directories that start with "s", which is OK, but then it also returns ALL of the contents of those directories, regardless of their initial.

Is there a way to limit the response to just the current directory and not its sub directories?

Thanks,

Gregory
 
Old 03-13-2009, 12:57 PM   #2
Ghostwheel
Member
 
Registered: Jun 2004
Location: Mid Michigan
Distribution: CentOS
Posts: 30

Rep: Reputation: 0
What distro are you using? ls -la s* doesn't recurse for me...
 
Old 03-13-2009, 01:11 PM   #3
gburtenshaw
LQ Newbie
 
Registered: Mar 2009
Location: Ottawa, Ontario, Canada
Distribution: CentOS
Posts: 2

Rep: Reputation: 1
Try this

ls -lad s*

I basically took a look at the man page for ls, did a search for "directory" and found the -d option. Seems to do the trick in my testing.
 
Old 03-13-2009, 01:55 PM   #4
Canis Polaris
LQ Newbie
 
Registered: May 2007
Posts: 15

Original Poster
Rep: Reputation: 0
Ghostwheel: RHEL 3

gburtenshaw: Thanks. I thought I tried that once before, but the "d" did the trick.
 
  


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
Format command shows "Cannot get current directory - I/O error" devn Solaris / OpenSolaris 1 06-18-2008 01:26 AM
"Permission denied" and "recursive directory loop" when searching for string in files mack1e Linux - Newbie 5 06-12-2008 07:38 AM
What does "Directory "/usr/src/linux" doesn't appear to contain kernel source." mean? jtp51 Linux - General 4 06-11-2007 12:22 AM
Problem with X consoles - "shell-init: error retrieving current directory" lowpro2k3 Slackware 4 03-26-2007 06:36 PM
i just finished typing "./configure" and "make" in mplayer directory... kublador Linux - General 4 02-22-2003 03:12 PM


All times are GMT -5. The time now is 02:38 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration