| 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`
|