- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- file name pattern matching in a script
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
08-12-2002 03:55 AM
08-12-2002 03:55 AM
I have a lot of file names with ascending numeric patterns in their names. e.g. file1234, file1235, file1236, etc.
I am trying to list the files whose names fall within a certain numeric range, e.g. file1234-file1239.
I've tried everything and am sure i am making a stupid omission somewhere, but can't waste any more time searching the web and reading for an answer. Can someone please take me out of my misery!
Thanks.
Dermot.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 04:01 AM
08-12-2002 04:01 AM
Re: file name pattern matching in a script
ls file123[4-9]
# cd /tmp
# touch file1230
# touch file1233
# touch file1234
# touch file1235
# touch file1236
# touch file1238
# touch file1237
# touch file1239
# ls file123[4-9]
file1234 file1235 file1236 file1237 file1238 file1239
# ls file123[5-8]
file1235 file1236 file1237 file1238
#
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 04:10 AM
08-12-2002 04:10 AM
Re: file name pattern matching in a script
this do it:
ls -alR file12[34-39]
or if there are more files, you can also do a:
ls -alR file12[34-39]*
using wild cards * or ?, it becomes easy.
Cheers
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 04:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 04:34 AM
08-12-2002 04:34 AM
Re: file name pattern matching in a script
Yogeeraj,
# ls file12[34-39]*
file12[34-39]* not found
#
the [34-39] doesn't work because the "range" doesn't work that way. The "range" is a single range. IE a-z works, but not aa-ku.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 04:43 AM
08-12-2002 04:43 AM
Re: file name pattern matching in a script
Don't you just love awk.. :)
Ceesjan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 05:09 AM
08-12-2002 05:09 AM
Re: file name pattern matching in a script
# ls file1*
file1 file1220 file1230 file1234 file1236 file1238 file1244 file1255
file1211 file1225 file1233 file1235 file1237 file1239 file1245
you can display ranges using this syntax, as in listing files that are
file1224-file1227 & file1234-file1237
# ls file12[2-3][4-7]
file1225 file1234 file1235 file1236 file1237
#
if you want all files starting at file1224 through file1237, then this syntax works:
# ls file122[4-9] file123[0-7]
file1225 file1230 file1233 file1234 file1235 file1236 file1237
#
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 06:38 AM
08-12-2002 06:38 AM
Re: file name pattern matching in a script
Many thanks.
Dermot