- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to list only files on HP-UX B.11.11 U 9000/800
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2007 12:22 AM
10-10-2007 12:22 AM
One dir is having files and dirs. I want to list only files. Can any one suggest how to do this?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2007 12:25 AM
10-10-2007 12:25 AM
Re: How to list only files on HP-UX B.11.11 U 9000/800
find . -type f
regards,
ivan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2007 12:26 AM
10-10-2007 12:26 AM
Re: How to list only files on HP-UX B.11.11 U 9000/800
find -type f
This will show only files, not directories.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2007 12:34 AM
10-10-2007 12:34 AM
Re: How to list only files on HP-UX B.11.11 U 9000/800
Soory but i want something like that:
Suppose i am under dir1:
under this i am having files f1.txt,f2.txt,f3.txt and subdir subdir1,subdir2.
Now if i use ls -lrt it will list all the files as well as dir.
If i use ls -lrt | grep "^d" it will list only dir.
Similarly i want some command which will display f1.txt,f2.txt.f3.txt and nothing else menas no files under subdir1 and so on.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2007 02:00 AM
10-10-2007 02:00 AM
Re: How to list only files on HP-UX B.11.11 U 9000/800
add option '-p' to your ls command, then pipe it to grep: '| grep -v /'
This exludes directories listed with '/' at the end (option -p of ls command)
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2007 02:04 AM
10-10-2007 02:04 AM
Re: How to list only files on HP-UX B.11.11 U 9000/800
V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2007 04:48 AM
10-10-2007 04:48 AM
Re: How to list only files on HP-UX B.11.11 U 9000/800
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2007 06:08 AM
10-10-2007 06:08 AM
Solutionfirst I want to remember, that there is more than (plain) files and directories:
sockets, named pipes, symbolic links, block and character devices, ... (*)
Excluding directories is one point, listing only plain files another.
Second: It seems necessary for me to get just filenames without additional stat information.
I want to highlight some aspects of the two solutions of Volker and Sandman (dropped options 'rt' which are meaningless here):
1) ls -p | grep -v /
- prints no additional status information
- prints anything but directories (including (*))
This is the best solution if you do not want to get plain files only.
2) ls -l | grep -v "^d"
- prints additional status information
- like 1)
3) ls -l | grep ^-
- prints additional status information
- list just plain files, which are not symlinks
Though you could use the option 'ls -F' and filter its additional markers out, this won't seperate the block+character devices.
My favourite (the 'sub' has six spaces in it):
ls -go | awk '/^-/ {for(i=1;i<7;i++) $i="";sub("^ ","");print}'
This will lead to correct results even when files containing whitespace are found.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2007 08:47 PM
10-10-2007 08:47 PM
Re: How to list only files on HP-UX B.11.11 U 9000/800
Thanks a lot for your sloutions.
Special thanks to Peter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2007 12:47 AM
10-11-2007 12:47 AM
Re: How to list only files on HP-UX B.11.11 U 9000/800
I got satisfactory answers for my query.