Bash:#: コマンドが見つかりません

Bash:#: コマンドが見つかりません

1週間前にKDEを使用してArch Linuxに移行しました。インストールするまではすべてうまくいきましたが、ibus-unikeyそれibus-qt以降は開くたびにkonsole次のエラーが発生しました。

bash: #: command not found

#入力してもkonsole何も起こらないので、これが一般的に使用されるコマンドだと思います。しかし、実行するとpacman -Ss #多くのものが表示されます。

私の質問:コマンドとは何ですか#?このエラーを解決するにはどうすればよいですか?

これは私のもので.bashrc.bash_profilePATH

$ cat .bashrc
   #
   # ~/.bashrc
   #

   # If not running interactively, don't do anything
   [[ $- != *i* ]] && return
$ cat .bash_profile
   #
   # ~/.bash_profile
   #

   [[ -f ~/.bashrc ]] && . ~/.bashrc


   alias ls='ls --color=auto'
   PS1='[\u@\h \W]\$ '


$ echo $PATH
   /usr/local/texlive/2015/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

補足1:@terdonが提案したように走った。

$ grep -FH '\#' ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases /etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment 2>/dev/null

しかし、何も見つかりませんでした。ところで、その命令が私に与えられました。

$ grep -P '(^|\s+)(\.|source) .' ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases /etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment 2>/dev/null
   /home/thuyenarc/.bash_profile:[[ -f ~/.bashrc ]] && . ~/.bashrc
   /etc/bash.bashrc:[ -r /usr/share/bash-completion/bash_completion   ] && . /usr/share/bash-completion/bash_completion
   /etc/profile:           test -r "$profile" && . "$profile"
   /etc/profile:   . /etc/bash.bashrc
   /etc/profile.d/locale.sh:    . "$XDG_CONFIG_HOME/locale.conf"
   /etc/profile.d/locale.sh:    . "$HOME/.config/locale.conf"
   /etc/profile.d/locale.sh:    . /etc/locale.conf

補足2:ファイル名を変更して開いて.bashrcみましたkonsoleが、エラーが消えました。エラーがで発生したと考えられます.bashrc

ベストアンサー1

このエラーは、bashの初期化ファイルの1つにエスケープ#(つまり)があることを意味します。または に\#ないようなので、ロードするときに bash が読み取る他のファイルの 1 つになければなりません。もちろん、次の1をすべて検索してください。~/.bashrc~/.bash_profile

grep -FH '\#' ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login \
              ~/.bash_aliases /etc/bash.bashrc /etc/profile \
              /etc/profile.d/* /etc/environment 2>/dev/null

これは、上記のファイルの1つにそのファイルが含まれていることを示します\#。そのファイルを編集して削除すると、すべてが正常に機能します。

コマンドが出力を返さない場合は、ファイルの1つが別の非標準ファイルを受け取っていることを意味し、そのファイルがエラーを引き起こします。この場合、質問を編集し、次のコマンドの出力を追加します。

grep -P '(^|\s+)(\.|source) .' ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login \
                              ~/.bash_aliases  /etc/bash.bashrc /etc/profile \
                              /etc/profile.d/* /etc/environment 2>/dev/null

これにより、他のファイルをソースするすべてのインスタンスが印刷され、正しい方向を指す必要があります。

より一般的には#コマンドではなくコメントです。その後のすべての内容は無視されますbash。したがって、 を実行するとpacman -Ss #実際にはpacman -Ss自分で実行することになるので、多くの結果が得られます。


1 この文書の一部はここには関係ありません。たとえば、存在する場合は無視され、~/.profile新しい端末を開いたときに読み取られませんが、すべての場合はすべて検索できます。~/.bash_profile/etc/profile

おすすめ記事