I hope you're having a great weekend,
I'm trying to create a script that execute a for only if a variable is not empty and if the variable is empty execute the command just one time, something like the following:
#!/bin/bash
X=$1
function execute
{
if [ ! -z $X ]
then
$*
fi
}
execute for count in 1 2 3 4
execute do
execute echo $count
echo $(hostname)
execute done