LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-04-2005, 02:06 AM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 31
list file name


I want to list the file name in the directory /tmp , if I use "ls -1 /tmp" ,it will list all file name and direcotoy in /tmp , if I want to list file only , want can I do ? thx
 
Old 07-04-2005, 02:23 AM   #2
mjrich
Senior Member
 
Registered: Dec 2001
Location: New Zealand
Distribution: Debian
Posts: 1,046

Rep: Reputation: 45
There's probably a more eloquent way of doing this (using ls -I) but a simple one would be
Code:
ls -F | grep -v / foobar
where foobar is your directory to list.

Cheers,

mj
 
Old 07-04-2005, 02:29 AM   #3
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 31
thx reply , but it still show the directory , could suggest what is wrong ? thx

ls -F | grep -v /tmp
 
Old 07-04-2005, 03:32 AM   #4
mjrich
Senior Member
 
Registered: Dec 2001
Location: New Zealand
Distribution: Debian
Posts: 1,046

Rep: Reputation: 45
Oops - had the format slightly back to front. Try this:
Code:
ls -F /tmp | grep -v /
The command translates to "list all items in the directory /tmp, but show a trailing slash to indicate the directories. Then pipe the results through 'grep', and filter out those items containing the slash".

Cheers,

mj

Last edited by mjrich; 07-04-2005 at 03:44 AM.
 
Old 12-07-2005, 02:58 AM   #5
prabuayyappan
Member
 
Registered: Sep 2005
Location: Coimbatore
Distribution: Prabuayyappan
Posts: 32

Rep: Reputation: 15
find /tmp -type f -maxdepth 1

This will display only the files in /tmp.
 
  


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
Finding the last in a file list .. hrafn Programming 1 03-21-2005 03:45 AM
Looping thru a list in a file BruceC Linux - Newbie 12 05-19-2004 08:51 AM
Piping file list through rm swingheim Linux - Newbie 4 01-17-2004 05:48 PM
C++ get file list Wynd Programming 2 06-09-2003 05:33 AM
can not list tar file juno Linux - Software 2 09-23-2002 02:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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