a script to clone a directory but with empty files :P

This is my first seriuous bash script. Thanks in advance to people from #bash and #sed, thanks to Jigen, Dani and Arbiter.

I have a directory with some file inside. I want to create another directory with the same file (with same name) but empty (created with touch).

My code take two parameters:

copianomi.sh -i input_dir -o output_dir

Here my code:

#!/bin/bash
# ./copianomi.sh -i dirInput -o dirOutput

NO_ARGS=0
if [ $# -eq "$NO_ARGS" ]  # Script invoked with no command-line args?
then
   echo "Usage: $0 dirInput dirOutput"
exit        # Exit and explain usage, if no argument(s) given.
fi

#
# check parameters
#
while getopts ":o:i:" Option
do
   case $Option in
      i 	) INPUT=$OPTARG;;
      o	) OUTPUT=$OPTARG;;
   esac
done

#
# Copy names
#
for NAME in "$INPUT"/*; do
   touch "$OUTPUT/${NAME##*/}"
done
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s