Find the answer to your Linux question:
Results 1 to 2 of 2
Hi I am tryinf to something relatively simple but seem unable to get this script working. I simply want to replace the number associated with a certain work. I am ...
  1. #1
    Just Joined!
    Join Date
    Jan 2006
    Posts
    15

    Bash scripting



    Hi

    I am tryinf to something relatively simple but seem unable to get this script working. I simply want to replace the number associated with a certain work. I am using sed. However when I incorporate the working sed command into my script it does not work any longer.

    #!/bin/sh
    for i in `seq 0 9`
    do
    x=24
    y=1000
    Result=`expr $i + $y`
    c="LIPID "$i
    d="LIPID "$Result
    echo $c
    echo $d
    e="'s/"$c"/"$d"/g' MCdemo.txt"
    f="sed "$e
    $f

    done



    This is the error:

    sed: -e expression #1, char 1: unknown command: `''

    Could someone please point out what is going wrong...

  2. #2
    Linux User muha's Avatar
    Join Date
    Jan 2006
    Posts
    290
    hiya, why not loose the f= and the $f part and just put in sed $e ???
    The last part of your script would look like:
    Code:
    e="'s/"$c"/"$d"/g' MCdemo.txt"
    sed $e
    Now what? You have Linux installed and running. The GUI is working fine, but you are getting tired of changing your desktop themes. You keep seeing this "terminal" thing. Don't worry, they'll show you what to do @
    <~ http://www.linuxcommand.org/ ~>

Posting Permissions

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