Results 1 to 9 of 9
Hi, the folders in my directory are :
01 02 03 .... 26 27 and I want to do a search between folders 23 and 24 so this is my ...
- 05-27-2011 #1Just Joined!
- Join Date
- May 2011
- Posts
- 6
zcat find from a range of folders?
Hi, the folders in my directory are :
01 02 03 .... 26 27 and I want to do a search between folders 23 and 24 so this is my command
$ zcat 2[3,4]/*/ktraw_somecode*.gz |raw-extract-messages -t
but I have no idea what to do it I am trying to look at files from 12 to 26, i tried
$ zcat [12,26]/*/ktraw_somecode*.gz |raw-extract-messages -t
but I got nothing
- 05-27-2011 #2
Try
Code:{12..26}You must always face the curtain with a bow.
- 05-27-2011 #3Just Joined!
- Join Date
- May 2011
- Posts
- 6
thanks it worked!!!
- 05-27-2011 #4Just Joined!
- Join Date
- May 2011
- Posts
- 6
another problem, if i want to know from 02 to 24 i typed {02..24}, but for the first 8 folders (02 to 09), I get the message
zcat: 9/*/ktraw_somecode*.gz: No such file or directory
why is the 0 getting dropped off?
- 05-27-2011 #5
yw.
Just a note:
The numbering with leading zeros is ..unfortunate.
a) If you would have >99 folders, you would need to add zeros to existing directories.
b) If you want to count e.g. from 1 to 14, then you would need to use some printf construct similar to
So I would suggest to rename the 01--09 folders, if possibleCode:a=1; printf "%02d" $a
You must always face the curtain with a bow.
- 05-27-2011 #6Just Joined!
- Join Date
- May 2011
- Posts
- 6
sorry i'm extremely new to linux so I do not follow. I do not have permission to change the names of the folders, since it's on a company database, the names are after days of the month, so from 01 to 30 usually.
So all I have permission to do is some simple cmd commands for information gathering, so I don't know how to incorporate your code into
zcat {02..26}/*/ktraw_somecode*.gz |raw-extract-messages -t
- 05-27-2011 #7
Ah ok.
For days, it is unlikely that they exceed 99
What I meant is this:
If the number of these directorys would increase (26..50..99),
and finally go over 100, then you would need to adjust all already existing
directorys to: 001, 002,.., 010, etc for consistency.
But for days it is ok, although you now need a temporary variable and a loop instead of just some bash-isms.
Which is less elegant and less performant, but at least more portable.
Something like:
Additionally, you would need to check for the existence of the directorys (not all months have 31 days, and february is a bit tricky)Code:for a in {2..26}; do; DAY=printf "%02d" $a; zcat ${DAY}/*/ktraw_somecode*.gz |raw-extract-messages -t ;doneYou must always face the curtain with a bow.
- 05-30-2011 #8Just Joined!
- Join Date
- May 2011
- Posts
- 6
Hi
Thanks so much ! I have another question, what if I want to go up a level in folders, say search from 04/11 to 05/26
I tried to zcat {04/11..05/26}/*/ktraw_somecode*.gz |raw-extract-messages -t apa
but it didn't work
- 05-30-2011 #9
The {} represents a number range. Not dates.
While a oneliner might still be possible for this particular problem, I have the impression, that you need a more general and re-useable approach.
I would suggest you develop a solution with a script language of your choice, like perl or python.You must always face the curtain with a bow.


Reply With Quote