Posts

Showing posts from April, 2022

script to copy a folder structure 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/{}" \;