Find the answer to your Linux question:
Results 1 to 2 of 2
i am trying to write to a new file (filename) using cat and i require to use a $ as this is in the previously written script, but when i ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    4

    Question $ simple use of the dollar sign $

    i am trying to write to a new file (filename) using cat and i require to use a $ as this is in the previously written script, but when i was testing to try and get a similar/simpler file to work...it doesn't

    here's what i have

    cat > filename << EOD
    #
    #
    1 2 3
    anything
    $hello
    #
    #
    EOD

    and i get "hello: undefined variable"

    but surely, it is just writing to text so it shouldn't matter about the $ ?

    please help

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    $ sign is special character. prefix \ (backslash) to escape it.
    Code:
    cat > filename << EOD
    #
    #
    1 2 3
    anything
    \$hello
    #
    #
    EOD
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

Posting Permissions

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