How to fix the terminal "source" command on OSX Catalina - macos

I try executing the below commands in my terminal.
$ source ~/.bash_profile or . ~/.bash_profile
and the system returns:
-bash: [[-s: command not found
I cannot think of anything extra information to provide.

I kept researching my issue and came across this stackoverflow post
I initially misunderstood the error message to mean the source command was not found. After reading the other post I tried running bash .bash_profile and the result was .bash_profile: line 11: [[-s: command not found. I had an error in my .bash_profile file. I commented out the line and tried running source .bash_profile and it worked.
The initial command not found did not relate to the source command, it related to the file I was running with source.
I hope this helps someone else.

Related

-bash: ≈: command not found (OS X Terminal Error), How to Fix?

Whenever I start up Terminal on my Macbook Air, I get this message:
-bash: ≈: command not found
How do I fix this error? I'm running Mavericks version 10.9.4 if that helps at all.
EDIT: Fixed this error by using the bash -x method, found out it was a random '≈' character left in ~/.profile that needed to be deleted. Thanks for the answers :)
To debug you can try this:
bash -x -l
(the -l might not be needed).
I definitely agree with Barmar, there is something in your bash startup scripts.
There is not a great way to do this, but here is the protocol to remedy it.
Confirm it is your bash profile by first killing the process with a control + C if it is hung. Then do a source ~/.bash_profile and see if you get that same error.
Backup your bash profile cp ~/.bash_profile bashprofile.txt
Then comment out part of your bash profile. With text wrangler you can do a command + slash.
Save, then do a source ~/.bash_profile and see if the error still prints.
Repeat with different areas of the script until you have isolated the infected region.

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.

Command not found ZSH Error after updating zshrc file

I recently updated some applications and now it is giving me error when I open any new tab in teminal.
Error it is giving:
/Users/priti/.oh-my-zsh/lib/completion.zsh:28: command not found:
whoami /Users/priti/.oh-my-zsh/lib/theme-and-appearance.zsh:10:
command not found: uname
/Users/priti/.oh-my-zsh/lib/theme-and-appearance.zsh:14: command not
found: uname getent:4: command not found: grep
I am sure something is wrong with the updated zshrc file, but I am not able to figure out what exactly the problem in that.
Problems I have faced till now are vi and grepcommand not working.For both output is command not found.
Thanks in advance for the same.
Reinstalling zsh solved the problem.
Some steps I followed after brew update might have caused this problem.

Basic command lines on Mac terminal not working

I changed the bash profile while trying to install mongodb and none of my command lines are working on terminal. I read online that I need to fix the $PATH but I can't even access it when none of my commands are working.
Help?
Mistakenly I also ran into same problem where to resolve this I had to reset my PATH variable to basic settings as below :
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin"
Once you set PATH variable now you can open the .bash_profile file in same terminal session only and make changes accordingly. This will resolve your problem.
Ok I found the answer from here:
"Open Terminal, and go to File (or Shell) -> New Command. Type in open -e .profile (or substitute some other file instead of .profile), and hit Run. That should open TextEdit with the file you want to fix; you can remove the offending lines there."
in my case i typed in nano .bash_profile and that allowed me to edit my bash profile and fix the issue.
can't use terminal from error in .bash_profile
Run this in terminal:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Get a "git command not found" error on mac though .profile file is updated

I have read this thread when I got the the
git: command not found (on OS X 10.5)
error
which basically said to update ~/.profile file with this phrase:
export PATH=$PATH:/usr/local/git/bin
I did that and it didn't work. but if I just write this code in the terminal the "git" command did work - but only until I have closed the terminal - then I need to retype this code whenever I want git to work.
My suspicious is that I have another ".profile" file somewhere in my mac and that the file I have updated is irrelevant (since it didn't work).
Is that the case and if so - how do I find this file?
Add this line to your ~/.bash_profile file:
source ~/.profile
This excellent super user answer explains why:
Difference between .bashrc and .bash_profile

Resources