Unix administration - Re: List only File names and not directory

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > May 2004 > Re: List only File names and not directory





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: List only File names and not directory
UNIX admin

2004-05-14, 12:49 pm

> I am working on Unix (Solaris). I want to create a list file from the
> files in my directory.
>
> Say my directory /home/sri contains the folloiwng files & folders:
> sria --> Folder
> srib --> Folder
> sri_f1.dat --> File
> sri_f2.dat --> File
> sriv3.dat --> File
> am.dat --> File
> blah.dat --> File
>
> Now I want to create a new file which contains the file (not
> direcotry) names starting from sri. That is, I want a list file called
> sri.lst which contains below data:
>
> sri.lst
> ========
> sri_f1.dat
> sri_f2.dat
> sriv3.dat
>
>
> I tried with the following command (ls -one) but this was not useful
> since it also lists the directories starting from sri
>
> ls -1 sri*
>
>
> Now how can i specify Unix to consider only files and not
> directories/files in subdirectories?


`find ./ -type f -print | tee /tmp/sri.lst`

Optionally, you can do:

`find ./ -type f -print | awk -F'/' '{print $NF}' | tee /tmp/sri.lst`


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com