I have a script to delete files older than x mins/days.
find $1 -type f -mmin +$2 -exec rm -f {} \; (name is test2.sh)
I need to pass arguments to test2.sh from another script test3.sh for example.
Assuming that the parameter expansions in test2.sh are correctly quoted as
find "$1" -type f -mmin +"$2" -exec rm -f {} \;
then test3.sh might have a call to test2.sh like this:
test2.sh "some file name" 5
$1 in test2.sh will expand to the string some file name and $2 will expand to 5.
This is assuming that test2.sh is located in a directory that is listed in the PATH variable of test3.sh. If not, use a full path (absolute or relative), for example:
./test2.sh "some file name" 5
It also assumes that test2.sh has first been made executable with chmod +x test2.sh and that it has a correct #!-line.
After clarification in comment below:
The test3.sh script could do (assuming it's a bash script):
read -p 'Enter directory name: ' dirname
read -p 'Enter number of days: ' days
minutes=$(( days * 60 * 24 ))
./test2.sh "$dirname" "$minutes"
The next step would be to validate the user's input so that $days is an actual integer and so that $dirname is a valid name of a directory.
If it's not bash but sh:
printf 'Enter directory name: '
read -r dirname
(etc.)
Most implementations of find also have -delete:
find "$1" -type f -mmin +"$2" -delete
-exec' to -mmin'
find ... -mmin +"$2 -exec ... maybe?
-mmin is empty (no +, no value), i.e. find ... -mmin -exec rm -f {} \;. But as Kusalananda says, you should really be using -delete instead of -exec rm -f {} \;. Check your single and double quoting for your find command. AND for the script test3.sh.