File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "file search for integer" Watch "file search for integer" New topic
Author

file search for integer

ajse ruku
Ranch Hand

Joined: May 06, 2005
Posts: 194
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
else
exit

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.

thanks,
Ajse
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11479
    
  94

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: 194
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"
else
echo "fine"
fi

then i get error following error

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

what could be the problem?pls suggest.

thanks,
ajse
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: file search for integer