Bashファイルbacktrack5 r2に予期しないマークがあります。

Bashファイルbacktrack5 r2に予期しないマークがあります。

ログインすると、次のエラーが発生します。

-bash: /etc/profile: line 1: syntax error near unexpected token ('

ファイルには次のコードが含まれています。

n# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))\n

# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).\n\nif

[ -d /etc/profile.d ]; then\nfor i in /etc/profile.d/*.sh; do\nif [ -r $i ];

then\n. $i\nfi\ndone\nunset i\nfi\n\nif [ "$PS1" ]; then\nif [ "$BASH" ];

then\nPS1=u@h:w$ \nif [ -f /etc/bash.bashrc ];

then\n.

/etc/bash.bashrc\nfi\nelse\nif [ "id-u" -eq 0 ];

then\nPS1=# \nelse\nPS1=$ \nfi\nfi\nfi\n\numask

022\nPT5HOME=/opt/pt\nexport PT5HOME

私はインターネットで検索しましたが、わかりましたか、私の問題と一致するものが見つかりませんでした(私の考えでは)。この問題を解決する方法は、コンピュータに問題を引き起こさないようですが、何かを知りたいです。どうしたの?

ベストアンサー1

書式を変更し、\n実際の改行文字に置き換えて、最初の偽の "n"を削除すると正常に動作します。したがって:

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r "$i" ]; then
      . "$i"
    fi
  done
  unset i
fi

if [ -n "$PS1" ]; then
  if [ -n "$BASH" ]; then
    PS1='u@h:w$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi
umask 022
PT5HOME=/opt/pt
export PT5HOME

おすすめ記事