[K12OSN] Scripters...I need your help! *please?*

Diego Torres Milano diego at in3.com.ar
Fri Nov 19 18:06:49 UTC 2004


> !#/bin/bash
> for x in `ls /home`; do
> echo "Doing $x ..."
> mkdir /home/${x}/win-backup
> chown ${x}.Users /home/${x}/win-backup
> 
> echo "Copying /opt/samba/profiles/${x}/My\ Documents/
> /home/${x}/win-backup"
> cp -Rf  /opt/samba/profiles/${x}/My\ Documents/ /home/${x}/win-backup
> 
> echo "Copying /opt/samba/profiles/${x}/Desktop/ /home/${x}/win-backup"
> cp -Rf /opt/samba/profiles/${x}/Desktop/ /home/${x}/win-backup
> 
> echo "Copying /opt/samba/profiles/${x}/Favorites/
> /home/${x}/win-backup"
> cp -Rf /opt/samba/profiles/${x}/Favorites/ /home/${x}/win-backup
> 
> chown -R ${x}.Users /home/${x}/win-backup
> 
> done

One minor improvement, if you are using bash, enable extglob if not
already enabled

$ shopt -s extglob

and you can combine the 3 cp command into 1

[...]
cp -a /opt/samba/profiles/${x}/*(My\ Documents|Desktop|Favorites)
/home/${x}/win-backup


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/k12osn/attachments/20041119/56985068/attachment.sig>


More information about the K12OSN mailing list