- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- listing 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
Discussions
Discussions
Forums
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
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
тАО11-29-2009 01:07 AM
тАО11-29-2009 01:07 AM
listing files
My directory contains lots of files including files appended with date.I want to list files with no date appended.For example i want to list only test.txt not text.txt.11112009
Please suggest
regards
himacs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2009 01:23 AM
тАО11-29-2009 01:23 AM
Re: listing files
If all files in that directory contains 2009 then you can try this:
# ll | grep -v 2009*
Let me know if you have any exceptions.
Regds..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2009 01:58 AM
тАО11-29-2009 01:58 AM
Re: listing files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2009 05:30 AM
тАО11-29-2009 05:30 AM
Re: listing files
ls | perl -ne 'print if (!/\d{6}\d*$/)'
cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2009 05:34 AM
тАО11-29-2009 05:34 AM
Re: listing files
ls | sed 's/\(.*\)[0-9][0-9][0-9][0-9][0-9][0-9][0-9]*$/\1/'
would chop off the digits at the end, if 6 or more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2009 05:39 AM
тАО11-29-2009 05:39 AM
Re: listing files
perl -ne 's/(.*)[^0-9][0-9]{6}[0-9]*$/\1/; print;'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2009 07:05 AM
тАО11-29-2009 07:05 AM
Re: listing files
If its a single directiory then do "ls -lrt" and you will get the files with sorted date recent modify at last.
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2009 09:07 AM
тАО11-29-2009 09:07 AM
Re: listing files
# ll *.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-29-2009 09:45 AM
тАО11-29-2009 09:45 AM
Re: listing files
Depending on your exact objectives, this might help:
# ls | grep -Ev "[0-9]{6}"
This will filter out files whose size is 6-digits in length if you do a long 'ls' listing, though (i.e. 'ls -l') so, this would correctly report files from that, too:
# ls -l | awk '$NF!~/[0-9]{6}/'
The assumption here is that a date that is part of the filename is exactly 6-digits long. If you always use the format of "MMDDYYYY" as you suggest in your example, a better expression might be:
ls -l | awk '$NF!~/[0-1][0-9][0-3][0-9][20][0-9][0-9]/'
In this case, the YYYY portion is assumed to be the year 2000 or later.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-30-2009 01:26 AM
тАО11-30-2009 01:26 AM
Re: listing files
Then exclude that pattern:
ls !(*.[01][0-9][0-3][0-9][12][0-9][0-9][0-9])
>JRF: You probably didn't want [20]:
ll | awk '$NF !~ /[0-1][0-9][0-3][0-9]20[0-9][0-9]/'