'Bash script produces different output when run and when run in comand line

I want to find all files with a specific name and copy them in a folder.

find FOLDERTOSEARCH -iname SEARCHTAG -type f -exec cp '{}' FOLDERDESTINATION \;

When I run this command in my shell it copies two files.

I wanted then to make it a script so I wrote:

#!/bin/bash
mkdir $3 
find $1 -iname $2 -type f -exec cp '{}' $3 \;

And then I called it from shell with: findcopy.sh FOLDERTOSEARCH SEARCHTAG FOLDERDESTINATION

And here it just copies one file.

I am new to bash.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source