script to copy a template directory and omit files

The following script will copy a directory structure from a source to a target and omit files, copying only folders (directories)


#!/bin/sh


if [ -z "$1" ] ; then

echo "Please give a source dir"

echo "otherwise I will assume that the source is ".`pwd`

echo "Synax: cp-dirsonly.sh sourcedir/ targetdir/"

sourcedir="./"

fi

if [ ! -z "$1" ] ; then

sourcedir=$1

fi

if [ -z "$2" ] ; then

echo "Please give give a target dir"

exit

fi

find $sourcedir -type d -links 2 -exec mkdir -p "$2/{}" \;

Popular posts from this blog

ZFS syntax (updated)

/var/log/journal taking up lots of space

throttle traffic on apache