“export: command not found [duplicate] - macos

This question already has an answer here:
How to restore .bash_profile on a mac? None of my unix terminal are working [closed]
(1 answer)
Closed 2 years ago.
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!

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.

I had a similar problem, the culprit was non-breaking space between export and the name of the variable.
To resolve the issue, just replace it with a regular space character.
Details:
I had the following in .bash_profile:
export a=foo
When I start new terminal, I would get
-bash: export a=foo: command not found
If we run xxd on the file, however, we can plainly see the problem (dots are non-printable characters:
$ cat .bash_profile | head -n1 | xxd
00000000: 6578 706f 7274 c2a0 613d 666f 6f export..a=foo
Byte sequence c2a0 stands for non-breaking space

Related

Terminal not answering

I began noticing random bash: some_command: command not found on startup of bash so I tried switching to sh, but it also said bash: sh: command not found so I tried to restart bash and yet, bash: bash: command not found and I haven't changed any bash files. Please help...
Maybe the PATH variable is not set or empty?
Bash uses PATH environment variable to search for commands, unless an absolute path is used. It is a colon-separated list of directories in which the shell looks for commands: try man bash
You should try to display the list of directories where bash is looking for command with:
printf "%s\n" "${PATH}"
By default on my ubuntu 20.04 LTS, the above command output is:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Trying to add alias in .bashrc file [duplicate]

This question already has answers here:
Command not found error in Bash variable assignment
(5 answers)
Closed 3 years ago.
I need to add permanent alias for bash terminal so that I don't have to set them always after logging in.
I am adding alias command to .bashrc and trying to install the .bashrc file again using the source command.
pxxxxx#pxxxxx:~$ cat .bashrc | tail -2
alias name1='command1'
alias name2='command2'
pxxxxx#pxxxxx:~$
pxxxxxx#pxxxxxx:~$ cat .bashrc | grep export
export EDITOR='vi'
export SHELL= /usr/bin/bash
Now,​ whenever I am logging in into bash or running the following command:
$source .bashrc
I am getting the following error:
pxxxxx#xxxxxx:~$ source .bashrc
bash: export: `/usr/bin/bash': not a valid identifier
I think the issue is with your second export: you say it looks like:
export SHELL= /usr/bin/bash
Try changing it to read:
export SHELL="/usr/bin/bash"
The space after the equals would break setting it as a variable. The quotes aren't necessary, but help stop word splitting.
I can't reproduce the error you're having, but when I try to source a .bashrc with that in there it just fails to return.

ubuntu : how to clear $SHELL history

No command 'exprt' found, did you mean:
Command 'expr' from package 'coreutils' (main)
exprt: command not found
i got this msg everytime i open the terminal. 'exprt' is my typo error during installation. I've tried
# history -c
# history -cw
but it still can't get rid of this problem, especially when
# exec $SHELL
it prompt the same error as well
any solution? I'm newbie to ubuntu...
Could this just be a typo in one of your shell configuration files?
Try running the following to search your .profile, .bash_profile, .bashrc, and so on for the offending line:
grep 'exprt' ~/.*
If you find the typo, edit the line so that is says "export" instead of "exprt", if that is what it should be.

Unable to successfully execute some commands in Cygwin

I installed Cygwin64 in my 64-bit Windows 7 machine. The following commands failed executing, however, by displaying the error messages below. Could you help providing a resolution please?
$ ll
-bash: ll: command not found
$ clear
-bash: clear: command not found
However, the command ls -l worked...
$ ls -l
total 0
Also i tried by un-commenting the following line in .bashrc file in my home dir -
# alias ll='ls -l'
But it didn't help either!
After you uncomment the alias, you should start a new Cygwin shell for it to take effect. The .bashrc file is actually a script that is sourced when bash starts.
clear is not a Cygwin (Unix) command. Just use Ctrl-L instead.

Unknown bash scripts running when terminal opens?

I am not exactly sure what's happening here - I open a terminal window on my mac and see the following:
Last login: Tue Jun 26 00:36:08 on ttys002
-bash: : command not found
-bash: : command not found
This seems to me like some file is being executed whenever I open a new terminal window, but I have no idea how I'd find this file. Is there some list of files that run when terminal opens that I could find easily? I'd love to know what is happening here (and how it came about in the first place)
grep Sorry $(grep -l Thank /etc/profile /etc/bash* ~/.bashrc ~/.bash_profile ~/.profile) /dev/null
And (when you are lucky) you will find the places where are these strange commands with Thank and Sorry.
It is possible although does these lines are produced during some command substitution.
In that case you will not find the strings. I would recommend then add set -x to ~/.bash_profile to find the string that produces these messages.
Check .bashrc, .profile and .bash_profile. Specifically, I have a feeling you have a String marked with inverted commas, which is then being tried to execute
From the bash manual:
When bash is invoked as an interactive login shell, or as a
non-inter‐
active shell with the --login option, it first reads and executes com‐
mands from the file /etc/profile, if that file exists. After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the first one that
exists and is readable.

Resources