• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

file search for integer

 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic