I have been trying to edit my environment variables. I referred to the sites but its not working. I should mention that I am very new to Mac and I'm using it because my workplace has it. When I enter the command

touch ~/.bash_profile; open ~/.bash_profile 

in the Terminal, it says

-bash: touch: command not found
-bash: open: command not found

though it did open the file once before.

  • What does echo $PATH print? The path variable contains a list of places to search for ‘touch’ and ‘open’, so if it’s missing or invalid your shell won’t be able to find these commands. – grg Mar 13 '20 at 7:46
  • If it has Catalina, I doubt that bash commands would work there. in any case, you can follow this step by step guide: apple.stackexchange.com/a/371665/313842 you might need to see zsh variation for PATH syntax – anki Mar 13 '20 at 9:59
  • touch is used to set the modification and access times of a file and if it doesn't exist creates it. Out of curiosity, where (the referred sites) did you get instructions to use that command and secondly, you said it opened it before - what changes did you make (I'm assuming you used Text Editor as it would be the default)? – Allan Mar 13 '20 at 13:02
  • @Akash, you need to install command line tools from Apple to have touch. Use this command from terminal: xcode-select --install (it is free). – Yoan Mar 13 '20 at 15:26

First check that your path variable is working or not just type (echo $PATH) from terminal it will return the O/P like: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin if saying "commond not found"

Then you have to PATH variable to setup path variable below steps

1) vi /etc/paths it's will vi editor to edit type "I" and enter below mention lines

/usr/local/bin /usr/bin /bin /usr/sbin /sbin

2) press esc and type wq to save exit.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .