Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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)
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.
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:
Now, I've never tried that (and can't at the moment) and I don't know if it'd work with the 'M' appended on the end. But I do know that with awk the first part is the condition part and the part in the curly-braces {} is the action part. It says "If the first column has a numeric value greater than 5.0 then print out the whole line". I'm assuming that column/field one is the column with the size value in it (the fields are separated by a space. You can change the field-separation character by specifying the -F switch for awk before you put the command in the single quotes).
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:
The numeric value of a string is the value of any prefix of the string that looks numeric; thus the value of 12.34x is 12.34, while the value of x12.34 is zero. The string value of an arithmetic expression is computed by formatting the string with the output format conversion OFMT.
If you've never used awk before, just know that $1 is the variable for the first field, $2 is for the second field, etc. And $0 is for the whole line. So, because I wouldn't know which field it is that the number is at, I couldn't write the exact command for you. But you can figure that out.
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
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)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.