# Unexpected token on bash file backtrack5 r2

When I log in, appears the following error:

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

Inside the file there is the next code:

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

I've searched around on internet but I didn't find something understandable or that matches with my problem (I think), how could fix this, it seems not to trouble anything with the computer, but I'd like to know what it's going on.

-
@jw013 that is the way the code is inside the file... –  poz2k4444 Sep 17 '12 at 21:06
@jw013 Hope it's ok now –  poz2k4444 Sep 17 '12 at 21:08
If that is true, then that is the reason for the error - bash doesn't know what to do with the very garbled formatting. I'd recommend just retyping it. Where did you get this horrendous profile? Did Backtrack really ship with this? –  jw013 Sep 17 '12 at 21:12
@jw013 yep, I did not mess up with the file, I reformat a little the code just to see it better, how can I correct it?? –  poz2k4444 Sep 17 '12 at 21:18
Replace all the \n with actual newlines and delete the very first n. –  jw013 Sep 17 '12 at 21:23

Fix the formatting, replace the \n by actual newlines and remove the spurious 'n' at the beginning, then it works. Thus:

# /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
PT5HOME=/opt/pt
export PT5HOME

-
Thanks a lot, it works perfectly, why bash doesn't support \n or why I have to reformat the code? –  poz2k4444 Sep 17 '12 at 22:20