- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Problem with wilcards
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
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
тАО07-21-2005 12:24 AM
тАО07-21-2005 12:24 AM
I am trying to mach files named like this:
file1.200705152407
where the digits 200705 are day, month and year.
I want to list all the files that matches the pattern:
file1.(any day)MMYY(any five numbers)
How can I do it? I tried with *, ?, but i does not work.
Regards,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 12:25 AM
тАО07-21-2005 12:25 AM
Re: Problem with wilcards
file1.(any day)MMYY(any SIX numbers)
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 12:36 AM
тАО07-21-2005 12:36 AM
Re: Problem with wilcards
# ls -1
file1.010203123451
file1.020203123441
file1.020203123451
file1.020303123451
# ls file1.??0203??????
file1.010203123451
file1.020203123441
file1.020203123451
This displays all the files from 0203. Is this not what you want?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 12:43 AM
тАО07-21-2005 12:43 AM
Re: Problem with wilcards
Often it's actually easier to simply punt and do an ls (of everything, or ls file1*) and pipe to enhanced grep for more serious regular expression evaluation:
ls | grep -E -e '^file1\.[0-9]{12}$'
which would list file1.followed by exactly 12 digits which seems to be a simpler statement of your problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 01:58 AM
тАО07-21-2005 01:58 AM
Re: Problem with wilcards
# ls -1 file1.[0-9]*
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 05:59 PM
тАО07-21-2005 05:59 PM
Re: Problem with wilcards
Thank you for your responses!!! It happens in a script. If I put in the script:
file1.*${MONTH}${YEAR}*
... it works; but if I put
file1.??${MONTH}${YEAR}??????
....it does not works:
file1.??0605?????? not found
What is wrong?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 06:50 PM
тАО07-21-2005 06:50 PM
Re: Problem with wilcards
you said:
file1.(any day)MMYY(any five numbers)
but you made six '?' at the end:
file1.??${MONTH}${YEAR}??????
That can't work!
You have to make exactly as much '?' as numbers you search.
So with 5 '?' it should work.
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 06:57 PM
тАО07-21-2005 06:57 PM
Re: Problem with wilcards
Can you show us your list command?
V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 08:33 PM
тАО07-21-2005 08:33 PM
Re: Problem with wilcards
file1.200705
#!/bin/ksh
#list.ksh
# User Input
Month="" # two digit example 09
Year="" # two digit 05
LS=`which ls`
$LS file1.??${Month}${Year}?????
exit 0
# end
chmod 755 list.ksh
./list.ksh
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 08:40 PM
тАО07-21-2005 08:40 PM
Solutionls command will use ? * as pattern matching not with regular expression.
ls file1.??<2digit><2digit>??????
It will try to find files with pattern match of file1.two digits <2 digits><2 digits> <6 digits> else it will try to match for,
ls file1.??0205??????? named file which is created as touch file1.??0205??????
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2005 12:43 AM
тАО07-23-2005 12:43 AM
Re: Problem with wilcards
# ls -1 file1.*${MONTH}${YEAR}*
OR
# ls -1 | grep -E file1.??${MONTH}${YEAR}??????
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2005 02:42 AM
тАО07-23-2005 02:42 AM
Re: Problem with wilcards
I don't understand why your approach should not work. I tried it and it worked.
Can you give us more details about which shell you use and what you do with the pattern in the script?
greetings,
Michael