rveri
April 26, 2013, 12:56pm
1
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 :
arch1_171034_667780.dbf to arch1_171063_667780.dbf
files.
Thanks .
Yoda
April 26, 2013, 12:59pm
2
ls arch1_1710{34..63}_667780.dbf
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.
Yoda
April 26, 2013, 1:11pm
4
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.
A more portable pathname pattern matching approach:
arch1_17103[4-9]_667780.dbf arch1_1710[45][0-9]_667780.dbf arch1_17106[0-3]_667780.dbf
Regards,
Alister
rveri
April 26, 2013, 3:35pm
6
Hi Yoda,
it did not work,
*arch1_1710{34..63}_667780.dbf not found
The shell is not bash , but it is hp-ux ksh , k shell.
Thanks.
Yoda
April 26, 2013, 3:44pm
7
Alright, then use Alister's solution which is portable and will work in HP-UX
rveri
April 26, 2013, 3:48pm
8
Yes, Yoda, Thanks for the update.. Alister's one worked all right.
Worked perfectly with ls to get the desired output:
arch1_17103[4-9]_667780.dbf arch1_1710[45][0-9]_667780.dbf arch1_17106[0-3]_667780.dbf
Thanks everyone ...