little help for regexp
Hi folks
I'm little confused with the regexp syntax. To show the numbers from 3 to 7 I'm using: [3-7] How to show the numbers between 3 and 70 ? kregexpeditor said, that [3-70] are the numbers 3 to 7 and 0 (or something like that) :confused: |
[] is for single characters
I'm no expert but I'm pretty sure that it doesn't work that way. The [...] thing is used for identifying a single character that fits the criteria in the braces. "70" is not a single character, is it? No, it's not. What "[3-70]" is probably interpreted as is "match anything between 3 and 7 and also 0". I don't have a Linux box in front of me right now to test that out though.
Maybe if you explain exactly what you need to do i could help a little bit more. -- the dudeMAN DavE |
I think you're right
Well, I have one big wget log file and I want to see how many files are bigger then 5MB. The file size is like 3.3M , 5.7M , 11M, 11.3M, etc I'm getting the size with: cat logfile |grep "Length"|cut -f3 -d" "|grep M |wc -l Any suggestions ? |
I know that awk might work well for you here. Unfortunately I can't test it out right now (as I'm on a public access internet connection running Windows 2000), but it'd be something like this:
Code:
# cat logfile | grep Length | awk '$1 > 5.0 {print $0}' | wc -l Sorry I can't think of much beyond that. -- the duDemAN daVE |
You got my brain working on this! And it's too bad/soo sad that I don't have a Linux box in front of me! Arg!
Anyway, I found a page that explains how awk interprets comparisons (whether string or numeric): http://ou800doc.caldera.com/en/SDK_tools/P_NumStr.html So, from what I read, I believe that if awk is comparing "6.7M" with "5.0" it'll compare it numerically, just like we want. Here's the quote: Quote:
Let me know what you figure out. -- the dudemaN DAVEEe |
awk sounds good. I've made a little test.
$cat testfile 245M 67M 112M 999M 4M 7M 5M $cat testfile |awk '$1 > 5 {print $0}' 67M 999M 7M 5M Unfortunately it has some problems with numbers, begining with 1-4. 245M is bigger than 5M. The "45M" part is probably like a string to him :scratch: And also my size is in format (14.6M). With the brackets awk recognize it as a string (i think). I can cut -c 2,3,4,5,6 and the result will be 14.6M, but some numbers are in (10M) format, so they will stay 10M) :scratch: Stuck again |
change delimiter, since i dont know which logfile you talking about, i can only give you the idea:
awk -FM '$1 > 5' print is default action, so it can be skipped. |
All times are GMT -5. The time now is 06:37 PM. |