Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am writing a BASH script. I am using RAR 3.93 on Ubuntu 10.08. I want to add a comment to an archive example.rar. The comment is "This is a comment".

rar c example.rar
Processing archive rarcomment.rar
Reading comment from stdin

But I want to add the comment from a variale instead of typing it from the stdin.

$Comment="This is a comment"

How can I do that?

share|improve this question
add comment

1 Answer

    export COMMENT="This is a comment
with multiple lines"
    echo "$COMMENT" | rar c example.rar

To write multiple line variables, just don't close the quote until you are done. To make it append to the echo, use quotes.

share|improve this answer
    
Cool. What if I want to add a new line in the comment, like "This is a comment\nGlad it is working." Obviously, \n wont work. –  DocWiki Nov 2 '11 at 11:14
    
I expanded the answer to illustrate this as well. –  Tatu Lahtela Nov 2 '11 at 11:33
add comment

protected by slhck Jun 5 '12 at 8:40

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.