title: IMAP UID MOVE in bash script - how to do it propper?
body: <p>I have script:</p>
  
  <pre><code>#!/bin/bash
  mailsrv='mailserver.uk';
  login='login@domain.uk';
  pass='veryhardpass';
  flw='/tmp/imap_msg';
  
  id=1;
  
  while true;
  do
          echo "Message ${id}" 1&gt;/dev/null
          curl -s --insecure --url "imaps://$mailsrv/INBOX/;UID=${id}" --user "$login:$pass" -o "$flw" || exit
  
          if [ -e $flw ]
          then
                  cat "$flw" | /home/user/script.php;
                  rm $flw;
                  imapcmd="UID MOVE $id \\Trash; EXPUNGE";
                  curl --verbose --insecure --url "imaps://$mailsrv/INBOX/" --user "$login:$pass" -X "$imapcmd" || exit
          fi
  
          id=`expr $id + 1`
  done
  </code></pre>
  
  <p>This script gets me an error:</p>
  
  <pre><code>&lt; A002 OK Logged in
  &gt; A003 SELECT INBOX
  &lt; * FLAGS (\Answered \Flagged \Deleted \Seen \Draft NonJunk)
  &lt; * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft NonJunk \*)] Flags permitted.
  &lt; * 1 EXISTS
  &lt; * 0 RECENT
  &lt; * OK [UIDVALIDITY 1515605811] UIDs valid
  &lt; * OK [UIDNEXT 1027] Predicted next UID
  &lt; A003 OK [READ-WRITE] Select completed (0.000 + 0.000 secs).
  &gt; A004 UID MOVE 1 \Trash;
  &lt; A004 NO [TRYCREATE] Mailbox doesn't exist: \Trash; (0.000 + 0.000 secs).
  &gt; A005 LOGOUT
  &lt; * BYE Logging out
  &lt; A005 OK Logout completed (0.000 + 0.000 secs).
  </code></pre>
  
  <p>I am stucked with this with few days.</p>
  
  <p>I tried:
  - many combinations in IMAP command,
  - googling &amp; googling,
  - trying find a good example of UID MOVE with dovecot,</p>