- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to list the files?
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
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
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
02-21-2008 02:23 AM
02-21-2008 02:23 AM
I have one dir which contains all txt files.
In one script i am using statement to list the files.
dir name is say dir.
ls $dir_path > /abc/def/listfile
it will list all files names in listfile.
Now this dir contains xml files as well. I want to list only txt file. I updated code like..
ls $dir_path/*.txt > /abc/def/listfile
It is listing the files in listfile along with full path. But in previous case only file names are coming. I want only name.
Can any please help me what needs to be changed?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2008 02:30 AM
02-21-2008 02:30 AM
Re: How to list the files?
or
find $dir_path -name \*.txt -exec basename {} \; >abc/def/listfile
.....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2008 02:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2008 02:50 AM
02-21-2008 02:50 AM
Re: How to list the files?
try
#ls $dir_path/*.txt |sed -e "s/$dir_path/ /"|cut -c 3-
Gives out only txt file names.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2008 03:40 AM
02-21-2008 03:40 AM
Re: How to list the files?
ls /path/to/files/*txt | rev | cut -d/ -f1 | rev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2008 04:01 AM
02-21-2008 04:01 AM
Re: How to list the files?
Out of all Dennis's reply is most useful in my case.
Thanks for your concerns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2008 12:25 PM
02-21-2008 12:25 PM
Re: How to list the files?
ls $dir_path | grep '\.txt$' > listfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2008 11:29 PM
02-21-2008 11:29 PM
Re: How to list the files?
ll $Dir_path|awk '/txt$/'
Rgds,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2008 11:39 PM
02-21-2008 11:39 PM
Re: How to list the files?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2008 11:28 PM
02-24-2008 11:28 PM
Re: How to list the files?
Laurent and Weertman actually i do not want to use cd.
Thanks Dennis again this is much better for me.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2008 11:49 PM
02-24-2008 11:49 PM
Re: How to list the files?
Thanks a lot i got solution of my problem.