0

I am using ubuntu 18.01,when I add below command to ~/.bashrc with vim:

# myself add
alias lsa='ls -lart'  
alias lsl='ls -lrt'    
alias lm='ls -al|more'

for example:

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# myself add
alias lsa='ls -lart'  
alias lsl='ls -lrt'    
alias lm='ls -al|more'

save ~/.bashrc then run command:

source ~/.bashrc

get error:

bash: alias:   : not found

If I comment out myself add code ,It's ok.

for example:

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# myself add
#alias lsa='ls -lart'  
#alias lsl='ls -lrt'    
#alias lm='ls -al|more'

What should I do?

When I run command:

 file ~/.bashrc

it output:

/home/hello/.bashrc: UTF-8 Unicode text

My problem be solved.Thank you all.

  • 2
    Check using some hex dump command (e.g. od -t x1z .bashrc) if there is any non printing character in your alias commands. That space between : and : is suspicious. – andcoz Oct 4 '18 at 8:31
  • @andcoz seem there is no.I only add 4 lines code. As above I say. – user261526 Oct 4 '18 at 8:38
  • @andcoz Yes ,you are right. error at I add 4 lines code.Thank you very much. – user261526 Oct 4 '18 at 8:56
0

Your .bashrc file is mostly likely to have DOS line endings \r\n instead of just \n. May be you edited the file with an editor from a DOS machine?

You need to clean it up by running dos2unix ~/.bashrc which converts \r\n to just \n. You can confirm the presence of DOS endings in the file by running file command,

file ~/.bashrc
/home/user/.bashrc: UTF-8 Unicode text, with CRLF line terminators

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy