Join Today
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2007
    Location
    53rB14
    Posts
    589

    Default Problems with sed!

    Can anybody tell does sed command allow user defined variables?

  2. #2

    Default

    If you need to cut some substring from string. you can use this way.

    TotalMem=`df -h "$1" | grep "$1" | "$BUSYBOX_FILE" awk '{ FS = "[ ]+" } { print $2 }'`
    A = `XXX` is mean execute XXX command and return result into A.

    I use awk command from busybox.
    Visit my Blog here.http://my.opera.com/eakrin

  3. #3
    Join Date
    Aug 2007
    Location
    Winnipeg, Canada
    Posts
    39

    Default

    If you're asking if you can set and use variables within a sed script, then the answer is no. sed isn't really a script language per se, its more of a macro utility to the ancient unix file 'ed'itor.

    sed can use your shell variables as input for text manipulation & pattern matching, but that's about it as far as I know.

    And as eakrin pointed out, you can also assign the output of sed (or any command with a return) to a shell var, ie. var=`echo "bigUGLYstring" |sed -e 's/UGLY/ugly/;s/big/BIG/'` Though sed has its place, awk is by far more useful in most circumstances and I'm surprised this wasn't included in the image. (and cut and wc and tr and... LOL)


 
+ Reply to Thread

Similar Threads

  1. Q: Telnetting problems Again
    By rn5a in forum A1200 General Chat
    Replies: 53
    Last Post: 02-21-2008, 07:14 PM
  2. Some problems.
    By iamnivas in forum A1200 General Chat
    Replies: 2
    Last Post: 12-19-2006, 09:26 AM
  3. Having some problems. Please help.
    By Alex2x3 in forum A1200 General Chat
    Replies: 6
    Last Post: 11-28-2006, 09:45 AM
  4. Help !! Problems on L6.
    By jingaro in forum RAZR Series
    Replies: 6
    Last Post: 10-08-2006, 02:29 PM
  5. known problems
    By anna_mcmillan in forum A780 General Chat
    Replies: 4
    Last Post: 12-29-2005, 04:36 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
Single Sign On provided by vBSSO

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1