This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file search for integer

 
ajse ruku
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11833
181
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to look at what a scripting language such as awk or perl can do for you.

For example:


Regards, Andrew
 
ajse ruku
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic