You have two issues:
First issue:
Your variable assignment does not work like you think it does:
FLAG="$PATH/$1_$3.flag" | tr -d \'
These are two commands separated by a pipe, meaning you send the output of the first command (the variable assignment) to the second command (tr). The second command will simply output the result. As the variable assignment has empty output, the output of tr is empty, too.
The variable assignment actually works, but as it is part of a pipe it runs in separate process and the main process including the commands afterwards (e.g. touch) can not access it.
Variable assignment including a command has to be done using command substitution:
FLAG="$(printf '%s' "$PATH/$1_$3.flag" | tr -d \')"
See also.
Second issue is that you overwrite your PATH variable:
PATH=/opt/omd/sites/icinga/var/TEST
FLAG="$PATH/$1_$3.flag" | tr -d \'
Now, tr will not work and give following error:
tr: command not found
I even get a nice additional information, but that might be bash or Ubuntu:
Command 'tr' is available in the following places
* /bin/tr
* /usr/bin/tr
The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable.
To fix this and also don't run into similar issues, follow the bash variable naming conventions:
path=/opt/omd/sites/icinga/var/TEST
flag="$(printf '%s' "$path/$1_$3.flag" | tr -d \')"
$FLAG, that should show your problem. It isn't what you think it is. Also, please don't use ALLCAPS for variable names in shell scripts. You just replaced your user's PATH variable with/opt/omd/sites/icinga/var/TESTin this script which means that all commands now need to be called with their full path. So, check what value$FLAGhas and then [edit] your question to tell us. Also show us what values your$1and$2have and what you want to do with them. – terdon Jun 02 '20 at 13:14PATHas variable name... See – pLumo Jun 02 '20 at 13:14echo $FLAG? Did you see what the value you are trying totouchis? Didn't you notice it was empty? – terdon Jun 02 '20 at 13:35echo "FLAG: $FLAG"so you can see what valueFLAGhas. You will see it has no value. For the reasons explained in pLumo's answer. – terdon Jun 02 '20 at 13:59