febrero 12, 2016

Copiar archivos y directorios al home linux shell




#!/bin/bash
UHOME="/home"
FILEPATH="/etc/skel/.procmailrc"
FILENAME=".procmailrc"
FOLDER1PATH="/etc/skel/spamassassin"
FOLDER1NAME="spamassassin"
FOLDER2PATH="/etc/skel/.spamassassin"
FOLDER2NAME=".spamassassin"
# get list of all users
_USERS="$(awk -F':' '{ if ( $3 >= 500 ) print $1 }' /etc/passwd)"
for u in $_USERS
do
_dir="${UHOME}/${u}/"
if [ -d "$_dir" ]
then
/bin/cp $FILEPATH $_dir
/bin/cp -a $FOLDER1PATH $_dir
/bin/cp -a $FOLDER2PATH $_dir
chown $(id -un $u):$(id -un $u) $_dir${FILENAME}
chown -R $(id -un $u):$(id -un $u) $_dir${FOLDER1NAME}
chown -R $(id -un $u):$(id -un $u) $_dir${FOLDER2NAME}
fi
done



Fuente: http://www.cyberciti.biz/tips/linux-unix-shell-batch-copy.html

No hay comentarios:

Se ha producido un error en este gadget.