Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

If I try to save to a message to an IMAP folder with the command save 1 +FOLDER/"Folder withSpaces" in heirloom-mailx, instead of saving, mailx spits out No applicable messages from {Folder/"Folder, withSpaces"}. For folders without spaces, it successfully appends the message to the folder, as desired. Can anyone offer me a clue as to why this is, so that I may fix it? I've googled, but have been unsuccessful in finding an answer. Thanks!

share|improve this question

To quote from the mailx manpage:

  • An argument can be enclosed between paired double-quotes "" or single-quotes ''; any white space, shell word expansion, or backslash characters within the quotes are treated literally as part of the argument. A double-quote will be treated literally within single-quotes and vice versa. These special properties of the quote marks occur only when they are paired at the beginning and end of the argument. [emphasis added]

So quotes in the middle of an argument don't work (unlike most shells). But you can't say "+FOLDER/Folder withSpaces" either, because the manpage also says:

  • If the filename begins with an unquoted plus sign, and the folder variable is defined, the plus sign will be replaced by the value of the folder variable followed by a slash. [emphasis added]

So if you use quotes, the + won't be special anymore. You'll have to fall back to backslash escaping:

save 1 +FOLDER/Folder\ withSpaces

ought to work. (Actually, I'm not certain that "+FOLDER/Folder withSpaces" won't work; you might try it just to see if I've misinterpreted the manpage.)

You might consider renaming the folder, say to Folder_withUnderscore or Folder-withHyphen.

share|improve this answer
Unfortunately, escaping the space (rather than quoting) does not work: it spits out the error "Referencing beyond EOF". Strangely, folder navigation isn't hindered by spaces: I can escape the space or use quotes for just the foldername with spaces or use quotes around the whole argument, and all work. I might have to rename the folder to eliminate the space. – Sara Fauzia Jun 14 '11 at 23:18
@Sara, that sounds like a bug in mailx. You might try reporting it. – cjm Jun 14 '11 at 23:23
Thanks for the suggestion. I've e-mailed the developer, and will update this thread once I have a solution. – Sara Fauzia Jun 15 '11 at 1:41

Looking more at the mailx manpage, I noticed the shortcut command, which accomplishes exactly what I wanted. I made a shortcut to the "All Mail" folder in Gmail, e.g. shortcut all "+[Gmail]/All Mail", and then save 1 all appends the message to the "All Mail" folder, as desired.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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