I am wring 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?

link|improve this question
feedback

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.

link|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
feedback

Your Answer

 
or
required, but never shown

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