Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

“export: command not found [duplicate]

Tags:

bash

path

macos

When I open terminal on my mac it shows

Last login: Sun Mar 15 22:12:02 on ttys000
-bash: “export: command not found
-bash: “export: command not found
-bash: “export: command not found
-bash: “export: command not found

(My echo $PATH)

MacBook-Air-Tim:~ timreznik$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Users/timreznik/bin:/usr/local/bin
MacBook-Air-Tim:~ timreznik$ 

I have already tried to edit my .bash_profile to

# general path munging
PATH=${PATH}:~/bin
PATH=${PATH}:/usr/local/bin

but it still keep showing me “export: command not found when I launch terminal...

P.S. all commands seems to work but my inner perfectionist is screaming!

like image 804
Tim Reznich Avatar asked Nov 04 '25 21:11

Tim Reznich


1 Answers

First, export is a shell builtin:

$ type export
export is a shell builtin

This means that PATH is irrelevant.

Second, the error message makes clear that the script is attempting to run the command “export. There is no such command:

$ “export
bash: $'\342\200\234export': command not found

The solution is to remove the spurious character from before the string export.

This misspelled command is in one of the shell's initialization files. These would include: ~/.bashrc, /etc/bash.bashrc, ~/.bash_profile, ~/.bash_login, ~/.profile, and any files they include.

Alternatively, the following commands will tell you which files and which lines in those files have the misspelled export command:

PS4='+ $BASH_SOURCE:$LINENO:' BASH_XTRACEFD=7 bash -xlic ""  7>trace.out
grep '“export' trace.out

For details on how the above works, see this post.

like image 142
John1024 Avatar answered Nov 07 '25 15:11

John1024