Would something like this suit your needs?
Code:
function ttouch()
{
if [[ $# -ne 2 ]]; then
echo "ttouch requires two parameters - date-format and file-name"
return 1
fi
touch -t "$1" "$2"
return $?
}
Which you would use in the terminal like this:
Code:
ttouch 01041337 filename.
The above usage would create a file called "filename" dated 1st of April of the current year at 13:37hrs. Or if the file already exists, it's timestamp will be set to April 1st @ 13:37hrs.
Or you could call it from another bash script, where the date and file-name are stored in variables:
The if statement in the ttouch function checks that ttouch received exactly two parameters. If we don't have exactly 2 parameters, the function returns with an error code (1).
Butif we do have two parameters, we use them in the 'touch -t' command.
NOTE: The final return value from the ttouch function will be the return code from the 'touch -t' command ($?).
Which may or may not be enough for you.
If that's not quite what you are looking for, show me the code you have so far and I'll see what I can do!
[EDIT]
BTW: I know you said you didn't want touch to output error messages to the screen. And my little function does echo an error message when less than two parameters are passed to the function. That error message is only there to illustrate what is going on in the code. If you don't want the error message going to the screen, you could either completely remove it, or redirect it to a log-file.
[/EDIT]