On 22 June 2012 09:14, <[email protected]> wrote:
>
>
>
>
> how do I modify so I only pass directory names, NOT file names in $j
>
> thanks for any pointers
>
> *1---------
> #!/bin/bash
> case $# in
> 1)
> DOMAIN=$1
> ;;
> *)
> echo "Usage: $0 <domain.name>" 1>&2
> echo "this archives" $1 " Maildirs "
> echo "all mail over 45 days is gzipped"
> exit
> ;;
> esac
>
> if [ -s /var/mail/vhosts/$1 ] ; then
>
> cd /var/mail/vhosts/$1
>
> for j in *@*
> do
> sudo -u#5000 /usr/local/bin/archivemail -d45 $j
> done
>
> exit
> fi
>
This should work
for j in $(ls -d /var/mail/vhosts/$1/); do
do_things_with $j (or use ${j%%/} if you don't want the last '/')
done
If you need to check if something is a dir, you can also do
[[ -d /var/mail/vhosts/$1 ]] && echo "It's a dir!"
> echo "no such domain" $i
> exit
> -----------------
>
>
> --
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
>
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html