Find the answer to your Linux question:
Results 1 to 3 of 3
I am trying to write a script to access sqlplus and use the output to replace the result in another file. But I am having some issues with it (This ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    vjy
    vjy is offline
    Just Joined!
    Join Date
    Oct 2004
    Posts
    10

    sed & script help


    I am trying to write a script to access sqlplus and use the output to replace the result in another file. But I am having some issues with it (This script is just a test script and I am just trying to print the updated value.

    #!/bin/bash

    I am not able to post the sqlplus connection, but it works.
    bb=$a
    echo a is $a
    echo bb is $bb

    var=he-llo

    echo "goodbye friend" | sed "s/goodbye/$var/"

    echo "goodbye friend" | sed "s/goodbye/$bb/"


    The output I get is

    a is 30-APR-10
    bb is 30-APR-10
    he-llo friend
    sed: -e expression #1, char 10: unterminated `s' command

    I am not sure why the last statement alone is not executing. Am I missing something?

    Thanks.

  2. #2
    Just Joined!
    Join Date
    Aug 2010
    Posts
    18
    Code:
    [root@server ~]$ bb="30-APR-10"
    [root@server ~]$ echo "goodbye friend" | sed -e "s/goodbye/$b/"
    30-APR-10 friend
    [root@server ~]$
    So I don't see any problems.
    Where do you assign $bb?

  3. #3
    vjy
    vjy is offline
    Just Joined!
    Join Date
    Oct 2004
    Posts
    10
    Thanks for the reply. I am assigning bb=$a in the 2nd line.

    Anyways it seems escaping the newlines did the trick.

    bb=${bb//$'\n'/}

    Thanks again.

  4. $spacer_open
    $spacer_close

Posting Permissions

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