Search code examples
linuxshellunixtouch

Im using touch to create a file in a folder on my desktop... Right when I tried this it says command not found


At first I had

touch $NAME_OF_FILE$DATE.$FILE_EXT

then I changed it to

PATH="Logs/"
touch $PATH$NAME_OF_FILE$DATE.$FILE_EXT

The file is created correctly in the folder, however only echos are being printed in there because says commands are not found like grep, awk, and others.

EDIT: The folder is already created on my desktop

Thanks Alan


Solution

  • PATH is an environment variable that specifies where executables are located and is used by your shell to look for commands executables (grep, awk, ...). You should not override it in your script.

    Try:

    MYPATH="Logs/"
    touch $MYPATH$NAME_OF_FILE$DATE.$FILE_EXT
    

    To understand what PATH is open a shell and type echo $PATH. You will see it contains the directories where your commands executables are.