Sed question

From: Craig Russell (crussell_1969_at_yahoo.com)
Date: 01/27/05

  • Next message: Shawn Guillemette: "NFS Mounts"
    Date: Thu, 27 Jan 2005 08:31:22 -0800 (PST)
    To: sunmanagers@sunmanagers.org
    
    

    I am trying to replace 10 lines in one file with 10
    lines from another data file. The 10 lines I am
    replacing I've setup with "holders" so they are easy
    for sed to find. Thus line 1 is set to "holder1" the
    2nd line is set to "holder2" and so on. The datafile
    only has 10 lines and they are in the order that they
    need to be inserted. My problem is that I cannot get
    sed to recognize the variables within the substitution
    command. This is what I am trying to use.

    x=1
    y=1
    for i in 30 36 41 49 56 63 67 76 81 85
    #replace matching line in file with $i
    #and then write new line to new file
    do
    string=`sed -n "$x"p ./datafile`
    echo $string
    echo $x
    sed 's/"holder$x"/"$string"/' ./template.$y
    >template.$i
    y=$i
    x=`expr $x + 1`
    done

    This command currenlty gives no error messages but
    does no substitutions. I have tried different quotes
    around the variables (holder$x and $string). The
    string variable is being set correctly. I have tried
    escaping the variables with back slashes.

    I apologize in advance if this is a newbie question.
    I have been out of the sys admin field for a little
    while and am admittedly a bit rusty.

    Thank you

    Craig Russell
    xspaneteast
    _______________________________________________
    sunmanagers mailing list
    sunmanagers@sunmanagers.org
    http://www.sunmanagers.org/mailman/listinfo/sunmanagers


  • Next message: Shawn Guillemette: "NFS Mounts"

    Relevant Pages

    • Re: Fomat function?
      ... standard method is to include as many zeros as needed as place ... holders, ... As String ... Dim PartsAs String ...
      (microsoft.public.vb.general.discussion)
    • Re: A little algorithmic problem...
      ... Daniel Kraft: ... Suppose I have a string with x place holders. ... How can I effectivly generate a set of all string possibilities? ... fixed and your optional values arrays are stored itself in an array ...
      (comp.lang.java.programmer)
    • Re: A little algorithmic problem...
      ... If I am not at the correct plcae, ... Suppose I have a string with x place holders. ... How can I effectivly generate a set of all string possibilities? ... Suppose these fixed Strings are stored in the array fixed and your optional values arrays are stored itself in an array values. ...
      (comp.lang.java.programmer)
    • Re: Replacing occurence of string in another string
      ... Frank Kabel ... > Suppose I have a string value with many lines of text. ... > there is several place holders and that I want to change ... > Is there a function for replacing one or all occurences of a string ...
      (microsoft.public.excel.programming)