LinuxQuestions.org
Visit Jeremy's Blog.
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 04-03-2007, 08:38 PM   #1
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Rep: Reputation: 38
Using 'ls' to list ONLY the current directory


Ok, This sounds simple, but it's escaped me thus far. When I use the command:
Code:
ls cron*
I get the following output:
Code:
cron.deny  crontab

cron.d:
sa-update

cron.daily:
000-delay.cron  beagle-crawl-system  makewhatis.cron  rpm
0anacron        cups                 mlocate.cron     tmpwatch
0logwatch       logrotate            prelink

cron.hourly:

cron.monthly:
000-delay.cron  0anacron

cron.weekly:
000-delay.cron  0anacron  makewhatis.cron
It seems to me that ls is recursing, when all I want is the list of files/directories in the current path.

I have to use the following command:
Code:
ls | grep cron
to get the results I want:
Code:
anacrontab
cron.d
cron.daily
cron.deny
cron.hourly
cron.monthly
crontab
cron.weekly

Is there a proper switch for ls that will give it to me?

Thanks.
 
Old 04-03-2007, 09:01 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 59
try
Code:
ls -d cron*
 
Old 04-03-2007, 09:04 PM   #3
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Original Poster
Rep: Reputation: 38
Yes, that is good stuff! I read that in the ls help, but it didn't sink in.

Thanks!
 
Old 04-03-2007, 09:07 PM   #4
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 59
no problem. i always find the LQ.org man pages easier to read than from the console.
 
  


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
How do I produce sorted list of files in current directory over a certain size? bangback Linux - Newbie 3 10-25-2006 12:11 AM
Inconsistent disk/directory usage using 'ls' essdeeay Linux - General 1 10-28-2005 07:36 AM
How to I flag 'ls' to list only the current sub-directories? davee Linux - Newbie 5 01-18-2005 09:49 AM
'ls' failing in specific directory realjustin Linux - General 1 09-20-2004 01:55 PM
list only files in current directory xscousr Programming 8 09-22-2003 07:35 AM


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