This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android 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: 193
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: 11404
    
  81

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: 193
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
 
Similar Threads
Buffered Readers and hashtables.
Confused about Arrays.binarySearch
Wrapper Class Instantiation
Wrapper Classes ,== and !=
wrapper class doubt