I have a bash
script like below. I want to redirect the logs to a specific directory based on the server where the script is running.
#!/bin/bash
# Host name of server
host=hostname
if [ "$host" == "XXXXXXX.com" ];then
logs=devlogs
else
logs=logs
fi
do something > /home/$USER/"${logs}"/abc_"${Date}" 2>&1
Here in the script If the server is XXXXXXX.com
I want to store the logs in /home/$USER/devlogs/abc_"${Date}"
else /home/$USER/logs/abc_"${Date}"
But even when the server is XXXXXXX,com
the logs are still being stored in /home/$USER/logs/abc_"${Date}"
What am I doing wrong here