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