This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes file search for integer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "file search for integer" Watch "file search for integer" New topic

file search for integer

ajse ruku
Ranch Hand

Joined: May 06, 2005
Posts: 196
Hi all,
I want to search in a file for any integer more that 10.
Its like
search file for i>=10
if true
send a mail

I am not able to find a command which can provide me an integer which is equal to or greater that 10 in a file.
Any help in this regard is highly appreciated.

Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11778

You might want to look at what a scripting language such as awk or perl can do for you.

For example:

Regards, Andrew

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
ajse ruku
Ranch Hand

Joined: May 06, 2005
Posts: 196
the following command works fine

awk '($1 > 10)' /tmp/info.txt

But when i try this in a script like

if [ awk '($1 > 10)' /tmp/info.txt ]; then
echo "problem"
echo "fine"

then i get error following error

line 6: [: ($1 > 10): binary operator expected

what could be the problem?pls suggest.

I agree. Here's the link:
subject: file search for integer
It's not a secret anymore!