I'm currently learning how to write simple scripts and can't get my head around a very simple problem.
I have the following command in my script...
touch ${DIRECTORY}/${FILE}
This command appears several times in my script and works fine in all instances except for one. For some reason, at one point only, it decides to include the slash in the filename that it's trying to create and I get the error...
cannot touch `/myfile.dat': Permission denied
At first I thought it was just probably down to my inexperience (which it probably is) but after doing a bit of research, I've seen this line used in countless examples working correctly. I can't understand - the same line is working fine in several other locations in my script!
Anybody care to shed some light on this? It's the inconsistency that's really annoying me. Can the commands surrounding this particular command affect its outcome?