Regex : help - How to write a range in ls


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Regex : help - How to write a range in ls
# 1  
Old 04-26-2013
Regex : help - How to write a range in ls

Experts,
Quick question for you guys:

- There are a lot of files.
- How to list all files in one command from arch1_171034 to 63 , in the below examples.


That means how to list with ls :
Code:
arch1_171034_667780.dbf  to arch1_171063_667780.dbf

files.


Thanks .
# 2  
Old 04-26-2013
Code:
ls arch1_1710{34..63}_667780.dbf

# 3  
Old 04-26-2013
That is not a regex exactly. It will feed every name between 34 and 63 into ls, which will complain about any files not actually found in that range. It may be sufficient for the purpose.
# 4  
Old 04-26-2013
That is correct.

I forgot to mention that it is not regex but a bash sequence expression that takes the form {x..y}, where x and y are either integers or single characters.
# 5  
Old 04-26-2013
A more portable pathname pattern matching approach:
Code:
arch1_17103[4-9]_667780.dbf arch1_1710[45][0-9]_667780.dbf arch1_17106[0-3]_667780.dbf

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 6  
Old 04-26-2013
Hi Yoda,
it did not work,
Code:
*arch1_1710{34..63}_667780.dbf not found

The shell is not bash , but it is hp-ux ksh , k shell.

Thanks.
# 7  
Old 04-26-2013
Quote:
Originally Posted by rveri
The shell is not bash , but it is hp-ux ksh , k shell.
Alright, then use Alister's solution which is portable and will work in HP-UX
This User Gave Thanks to Yoda For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sed/awk to delete a regex between range of lines

Hi Guys I am looking for a solution to one problem to remove parentheses in a range of lines. Input file module bist_logic_inst(a, ab , dhd, dhdh , djdj, hdh, djjd, jdj, dhd, dhp, dk ); input a; input ab; input dhd; input djdj; input dhd; output hdh; output djjd; output jdj;... (5 Replies)
Discussion started by: kshitij
5 Replies

2. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies

3. Shell Programming and Scripting

Regex to split a string and write the output in another file.

hi, i am trying to write a script to generate ouput in the following format: ##### buildappi abcd_sh nodebug.##### ##### buildappi ijk_sh nodebug.##### The given string is as follows: xtopSharedDLLs = "abcd_sh def_sh ijk_sh " \ + "jkl_sh any_sh... (15 Replies)
Discussion started by: Rashid Khan
15 Replies

4. Shell Programming and Scripting

Generate Regex numeric range with specific sub-ranges

hi all, Say i have a range like 0 - 1000 and i need to split into diffrent files the lines which are within a specific fixed sub-range. I can achieve this manually but is not scalable if the range increase. E.g cat file1.txt Response time 2 ms Response time 15 ms Response time 101... (12 Replies)
Discussion started by: varu0612
12 Replies

5. Shell Programming and Scripting

How do we write an exception in a Regex.

Hello, Actually this is a follow-up of my earlier request to identify Sentence Boundaries while generating snippets for a search engine. The basic regex I have written to delimit sentence boundaries handles numbers and acronyms but I cannot get it to handle cases of The full stops after Mr.... (3 Replies)
Discussion started by: gimley
3 Replies

6. UNIX for Dummies Questions & Answers

How to specify beginning-of-line/end-of-line characters inside a regex range

How can I specify special meaning characters like ^ or $ inside a regex range. e.g Suppose I want to search for a string that either starts with '|' character or begins with start-of-line character. I tried the following but it does not work: sed 's/\(\)/<do something here>/g' file1 ... (3 Replies)
Discussion started by: jawsnnn
3 Replies

7. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

8. Shell Programming and Scripting

print range between two patterns if it contains a pattern within the range

I want to print between the range two patterns if a particular pattern is present in between the two patterns. I am new to Unix. Any help would be greatly appreciated. e.g. Pattern1 Bombay Calcutta Delhi Pattern2 Pattern1 Patna Madras Gwalior Delhi Pattern2 Pattern1... (2 Replies)
Discussion started by: joyan321
2 Replies

9. Shell Programming and Scripting

Using REGEX within SED range search

test data: Code: sed -n '/^**$*/,/;/{/;/G;p;}' What i'm trying to do with the above regex (in bleu) identify upper/lower case select only when select is at the beginning of the line OR preceded by a space select is followed by a space or is at the end of the line. ... (13 Replies)
Discussion started by: danmauer
13 Replies

10. Shell Programming and Scripting

Read Write byte range/chunk of data from specific location in file

I am new to Unix so will really appreciate if someone can guide me on this. What I want to do is: Step1: Read binary file - pick first 2 bytes, convert from hex to decimal. Read the next 3 bytes as well. 2 bytes will specify the number of bytes 'n' that I want to read and write... (1 Reply)
Discussion started by: Kbenipel
1 Replies
Login or Register to Ask a Question