On Fri, Jun 22, 2012 at 05:34:40AM BST, Umarzuki Mochlis wrote: > below scripts stuck when i added id variable to a path. > > this script supposed to copy message files (from 18-22 june) from a > zimbra store/mailbox of a user and copied it into /tmp > > #!/bin/bash > echo "Username? then [ENTER]:" > read username > id=`/opt/zimbra/bin/mysql -e 'use zimbra;select id,comment from > mailbox;' | grep $username | cut -f 1` > mkdir /tmp/$username 2>/dev/null > for i in `egrep '(1[8-9]|2[0-2]) Jun 2012' > /opt/zimbra/store/0/$id/msg/0/* | cut -d : -f 1 | uniq` > do > cp $i /tmp/$username > done > > there must be something that i had missed...
1. Hard to tell, as you simply pasted the script instead of attaching an actual fine - the line breaks are wrong I take it. Please simply attach one next time. 2. Your problem is a bash problem per se as there's nothing bash specific in your script, you might as well change the hashbang to #!/bin/sh - it'll save you some resources ;^) 3. Backticks '`' can be tricky to work with, try using $() instead - they nest better, are cleaner, more readable, and they're POSIX. 4. If you need literal results, quote the command substitution - "$id". 5. Last but not least - debug your script! Regards, -- rjc -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20120623102403.ga11...@linuxstuff.pl