How to remove .000 from 1000.000 using grep command?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rameshjumgam
    New Member
    • Dec 2010
    • 10

    How to remove .000 from 1000.000 using grep command?

    Hi in my file im having value like
    cpu speed is 1000.000

    but i wants to pick only before special character .(dot) please help me someone ? thanks in advance
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Sounds like you need a regex (regular expression).

    Are you familiar with the command-line utilities awk or sed? Or possibly a scripting language like PERL or Python?

    Those all offer regular expression functionality and PERL and Python are usually contained in most base installs (awk and sed are almost always in command-line utilities).

    From there, I'd suggest something with a group. Groups are usually noted through parentheses - what you set to catch in between the parentheses will be caught. You could do (1000) in your script to test, and then catch something like ([0-9]+)\.

    If I remember my regexes correctly, that will capture any group of numbers before a period (a dot is a special character in a regex and needs to be 'escaped' to catch the dot symbol).

    Here are some links that might help
    awk - http://www.gnu.org/software/gawk/manual/gawk.html
    sed - http://www.gnu.org/software/sed/
    PERL - http://www.perl.org/docs.html
    Python - http://www.python.org/doc/

    Comment

    Working...