Results 1 to 2 of 2

Thread: SED help delete characters

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    15
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default SED help delete characters

    Hi Please help me to refine my syntax. I want to delete the excess characters from the out put below.

    -bash-3.00$ top -b -n2 -d 00.20 |grep Cpu|tail -1 | awk -F ":" '{ print $2 }' | cut -d, -f1
    4.4% us

    now i want to delete the % and us. How wil i do that to make it just 4.4.

    Thanks

  2. #2
    Member Shell_Life's Avatar
    Join Date
    May 2011
    Location
    Bahia, Brazil
    Posts
    99
    Thanks
    0
    Thanked 11 Times in 11 Posts
    Rep Power
    5

    Default

    If you have data with "4.4% us" and you want to remove "% us":
    Code:
     
    echo "4.4% us" | sed "s/% us//"

  3. The Following User Says Thank You to Shell_Life For This Useful Post:

    redtred (5th September 2011)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Solved] Matched characters - regular expression
    By jianma in forum Shell scripting
    Replies: 2
    Last Post: 17th June 2011, 02:03 AM
  2. sed + add a line with special characters ' to a file
    By massoo in forum Shell scripting
    Replies: 2
    Last Post: 24th May 2011, 04:26 PM
  3. [Solved] using characters incommands
    By kaykav in forum Ubuntu / Debian
    Replies: 2
    Last Post: 19th October 2010, 07:14 PM
  4. grep repeated characters
    By gyterpena in forum Shell scripting
    Replies: 0
    Last Post: 28th October 2008, 03:20 PM
  5. Replies: 2
    Last Post: 24th May 2006, 03:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •