Computing.Net > Forums > Unix > Grep based on file size

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Grep based on file size

Reply to Message Icon

Name: Big_Z
Date: May 21, 2004 at 11:19:34 Pacific
OS: AIX 5.1
CPU/Ram: RISC/1GB
Comment:

Hello,

I have a directory where a bunch of files live.. for example, the directory is named:

/opt/2004.05.21

There are quite a few files in the directory that are created daily and on an ongoing basis.

I am grepping (grep -c) for a certain word in a file. The filename ends with .0001 and is located in the /opt/2004.05.21 directory.

This file is always pretty big.. and all the other files in the directory are less than 2000 bytes.

Is there a way to only grep the file in this directory that is greater than 2000 bytes??

This grep will be embedded in a script and will give a value to a variable so if there are other commands besides grep that can accomplish this, that would help too.

Thanks!
Big Z



Sponsored Link
Ads by Google

Response Number 1
Name: Big_Z
Date: May 21, 2004 at 11:21:06 Pacific
Reply:

Forgot to mention that there may possibly be more than 1 file that has the .0001 extension. But only one that will be greater than 2000 bytes.


0

Response Number 2
Name: Dlonra
Date: May 21, 2004 at 17:19:58 Pacific
Reply:

find /opt/2004.05.21 -size +2000c -exec grep -H pattern {} \;



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Grep based on file size

AIX file size limit www.computing.net/answers/unix/aix-file-size-limit/4935.html

renaming files based on date arguments www.computing.net/answers/unix/renaming-files-based-on-date-arguments/2499.html

renaming a file based on systm date www.computing.net/answers/unix/renaming-a-file-based-on-systm-date/4875.html