#!/bin/bash
function repeat() {
#If there is at least one argument passed.
if [ ! -z "$1" ];
then
#"${@:2}" retrieves all arguments from the second argument onwards.
command="$1 \"${@:2}\""
echo "Command is: $command"
#Then keep repeating the entered command indefinitely.
while (true);
do
eval $command
sleep 1
done
else
echo "No command."
fi
}
repeat echo "hello"