Monday, May 6, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 670  / 3 Years ago, wed, september 1, 2021, 11:31:57

Over the last few days, I merged a home directory from a working install of 12.04 to an old home directory, I believe from an install of 10.04 (it was a bare driv)



I got the new drive to load and mount properly, but when I try and use the .bashrc entries from the 12.04 installation, things like the following alias:



alias banana='echo banana'


It produces the following errors:



-bash: $'
': command not found
-bash: $'
': command not found
-bash: $'
': command not found
: invalid shell option name
-bash: $'
': command not found
-bash: $'
': command not found
: invalid shell option name
-bash: $'
': command not found
-bash: $'
': command not found
-bash: $'
': command not found
-bash: $'
': command not found
-bash: .bashrc: line 36: syntax error near unexpected token `$'in
''
'bash: .bashrc: line 36: `case "$TERM" in


I can't find the text that is being referenced in that .bashrc file (it only works when I copy it from /etc/skel, and even then, after adding the alias and sourcing, then removing the alias and sourcing, it still produces the errors. The only way to get Bash working again is to re-copy the file from /etc/skel



It looks like I can't make any alterations to .bashrc without causing these errors. I suspect that it has something to do with readline or .inputrc, which were also having problems (though these seem to be resolved now). As of right now, there's no .inputrc in the /home/user directory.



Thanks for any help you can give!


More From » command-line

 Answers
1

Try this:



sed -i -e 's/
$//' ~/.bashrc


This will remove Windows-style line endings (CR characters -
). Now, if you source ~/.bashrc you shouldn't get any error.



Next, before to copy any content from other file, run the same command for that file:



sed -i -e 's/
$//' /path/to/file_from_where_you_copy

[#28496] Thursday, September 2, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
taigysel

Total Points: 33
Total Questions: 136
Total Answers: 114

Location: Singapore
Member since Wed, Jan 13, 2021
3 Years ago
;