I keep getting this message when I use the bash command to switch shells.
bash: i: command not found
I thought it was a path issue. So I check where the command is.
>type -a bash
bash is /usr/bin/bash
>which bash
/usr/bin/bash
>whereis bash
bash: /usr/bin/bash
Then I verified it was in my path.
>echo $PATH
/usr/bin:/etc:/usr/sbin:/usr/ucb:/u/user/bin:/usr/bin/X11:/sbin:.:/u/user/bin
Also just for the heck of it I try the full path of the command.
>/usr/bin/bash
bash: i: command not found
Any idea what is going on?
Hi,
The interesting thing here is that the error message seems to be coming from Bash itself, saying it can't find the command 'i'. I'd be inclined to look at your ~/.bashrc and ~/.bash_profile files, as well as the global versions of these files in /etc.
If I were to guess: at some point, someone's edited one of the Bash startup files in vi, and has pressed 'i' to go into insertion mode one too many times, and now there's an errant letter 'i' somewhere in the file.
OMG thank you. This has been driving me crazy.
You might also want to check if you have an alias for bash:
'alias bash' will tell you.
Hi,
Welcome to the forum ! I had considered the possibility of a bad Bash alias, but there's one clue that tells us that it can't be an alias issue that produced this error.
If we take a look at the error that the original poster reported, it was:
bash: i: command not found
Now the clue in question is the fact that the error comes from Bash, and not from the user's previous shell (which presumably cannot be Bash, or else they'd have no reason to be running Bash manually if that was already their shell).
For example, if I run the Korn shell, and set an alias for Bash that includes an 'i' by mistake, I get this instead:
$ alias bash=i\ bash
$ bash
ksh: i: not found [No such file or directory]
$
So here, the error comes from ksh, and not bash. Because the alias prevented us from actually running Bash, it was the existing Korn shell that told us it couldn't find a command called 'i'.
But in the case of the OP, the failure to find 'i' comes from Bash itself. That tells us that when the OP types bash, Bash is indeed being run, But then, in the process of Bash starting up, it is trying to run a command called 'i', failing to find it, and reports that error before returning the expected Bash prompt. And that, in turn, made me think the error must be a typo in the Bash startup files.
I did this:
Number6:~$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Copyright (C) 2007 Free Software Foundation, Inc.
Number6:~$ bash
Number6:~$ alias bash='bash i'
Number6:~$ bash
bash: i: No such file or directory
Number6:~$
Hi,
Sure - if you had a bad alias to Bash, and you were already running Bash and tried to start a new Bash shell, that is indeed what you would see.
But the OP mentions "... I use the bash command to switch shells". To me, that tells us that they're starting off in something other than Bash, otherwise they wouldn't talk about switching shells. And so for the error to be coming from Bash, it cannot be due to a bad Bash alias, otherwise the error would come from the shell they were already running prior to switching to Bash.
Admittedly it would depend on where exactly in the alias the 'i' occurred, and how their existing shell handled that (and if it got as far as running Bash or not). So whilst this is technically possible, unless the OP tells us otherwise, I think the startup files remain the most likely candidate here.
Also I tried to run the full command. So I wouldn't think there would be a way for an alias to effect a full command right?
I stand corrected! Running /usr/bin/bash would certainly bypass aliases (in whatever shell you start from); I agree with drysdalk- there is something fishy in the bash startup file(s) - look to /etc/bashrc, /etc/profile, /etc/profile.d/*