0

I'm trying to modify the ls command with an alias in my .bashrc file, and I'm getting some strange errors.

.bashrc file

export http_proxy="Some URL"  
export https_proxy=$http_proxy 

alias ls='ls --color'

Then, when I try ls, the output is

's: unrecognized option '--color
Try 'ls --help' for more information.

If I remove the alias from my .bashrc and run ls --color, I see the expected result.

I'm not sure what I'm doing wrong, but help would be appreciated. Each time I make a change, I do restart the terminal to ensure the .bashrc is reloaded. OS is Ubuntu 14.04.

Some things that might be relevant

  • The empty line in my .bashrc causes : command not found to be displayed to the terminal when I open up a new one.
  • If I run alias ls='ls --color' in the terminal, the alias works correctly.
  • Technically, I am on Windows, using Cygwin to SSH onto this Ubuntu VM.

Related questions
why alias names defined in .bashrc file are not working?
http://www.linuxquestions.org/questions/linux-newbie-8/bashrc-aliases-don't-work-267885/
Alias not working in Debian
https://unix.stackexchange.com/questions/44616/why-is-vim-creating-files-with-dos-line-endings

0

2 Answers 2

2

Found the problem. I noticed when I opened my .bashrc in vim, there was a little [dos] in the bottom.

I then ran dos2unix .bashrc to convert it to Unix file endings and the problem is fixed.

Upon further reading, it seems like Cygwin may have had something to do with the dos line endings. See https://unix.stackexchange.com/questions/44616/why-is-vim-creating-files-with-dos-line-endings.

0

I think you need to use double quotes for that. Double quotes preserve the complete meaning of what you type, while single does not. Read this for more info.

So your code should look like this

alias ls="ls --color"
4
  • Switched to double quotes as you suggested, and no change to the error message.
    – Dominic A.
    Jan 26, 2016 at 15:37
  • Is that your entire .bashrc file? if you could show us more we might be able to spot the problem. Jan 26, 2016 at 15:51
  • That's the entire .bashrc.
    – Dominic A.
    Jan 26, 2016 at 16:04
  • Ok. I'm glad you got it figured out. Jan 26, 2016 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .