Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

You must log in to answer this question.

protected by slhck Jun 5 '12 at 8:40

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

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

Not the answer you're looking for? Browse other questions tagged .