当我登录时,出现以下错误:
-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