Assistance with archival script

Shawn O'Shea shawn at eth0.net
Wed Nov 19 14:37:35 EST 2008


>
> #!/bin/bash
> DLDIR='/var/lib/samba/shares/xfer/All Downloads/incoming/'
> cd "$DLDIR"
> find . -maxdepth 1 -type d -exec echo /usr/bin/7z a -t7z -mx=0 {}.7z {} \;
>

Not that you _can't_ do it with find, but if I'm understanding your goal,
I'd do it like this (not 100% tested):
for i in *; do
   if [ -d "$i" ]; then
      /usr/bin/7za a -t7z mx=0 $i.7z $i
   fi
done

The [ -d <something> ] tests to see if something is a directory. $i is in
quotes there in case there are spaces in any of the file/directory names
that the test is checking (actually in retrospect, then the $i
s in the 7z command line probably need to be quoted for the same reason,
ignore the quotes altogether if you are certain uyou have nothing with
spaces in the filename)

Anyway, just another way to look at the same problem. Wonderful thing about
shell scripting :)

-Shawn


>
> Here's what it returns:
>
> /usr/bin/7z a -t7z -mx=0 ..7z .
> /usr/bin/7z a -t7z -mx=0 ./oh four.7z ./oh four
> /usr/bin/7z a -t7z -mx=0 ./two.7z ./two
> /usr/bin/7z a -t7z -mx=0 ./three.7z ./three
> /usr/bin/7z a -t7z -mx=0 ./one.7z ./one
>
> What I want to do is prevent find from outputting "." as a directory as
> it's creating a file named "..7z" with each of the subdirs within it.  I've
> had no luck with the man pages and Google (or more likely my search phrases)
> has failed me.  Could anyone point me in the right direction?  I'm open to
> suggestion, if you know of a better way to get the job done, I'm all ears
> (eyes?).
>
> If you need more detail, please let me know.
>
> --
> MDS
>
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20081119/93b616ca/attachment.html 


More information about the gnhlug-discuss mailing list