Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listing only files in a directory on UNIX 2

Status
Not open for further replies.

Shrini4u

Programmer
Aug 14, 2003
13
US
Hi,

How can I list only the filenames in a directory without showing the Directory names while listing a particular directory.

Thanks in advance.

Regards,
Shrini.
 
There are a lot of ways. One of them:
Code:
l /path/to/directory | awk '/^-/ { print $NF }'

Theophilos.

-----------

There are only 10 kinds of people: Those who understand binary and those who don't.
 
Hey thanks Theophilos.
Can you please tell me how can we do this without using the awk command?

Thanks in advance.

Regards,
Shrini.
 
You can replace awk by grep
[tt]
ls -l /path/to/directory | grep -v '^d'
[/tt]

Jean Pierre.
 
You can also use find:
Code:
find /path/to/directory -type f -level 0

or
Code:
find /path/to/directory \( -type f -o -type l \) -level 0
to include symbolic links

Theophilos.

-----------

There are only 10 kinds of people: Those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top