Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any option I can pass to ls to hide .un~ files from the output?

I want to be able to see all files (e.g. dotfiles) except .un~ files, so I need to run ls -A and add something to hide the .un~ files.

share|improve this question
up vote 2 down vote accepted

Homebrew does provide GNU ls through the coreutils package.

brew install coreutils

Then, you could alias your system ls to GNU ls, which Homebrew installs as gls instead in order to prevent overriding the usage of system binaries:

alias ls='/usr/local/bin/gls'

Alternatively, as outlined in brew info coreutils:

If you really need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc like:

PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"

Proceed with using GNU ls options if they better suit your needs, e.g.

ls -B

or similarly:

alias ls='/usr/local/bin/gls --hide=*~'
share|improve this answer

ls -B

Hides backups, files ending in ~

share|improve this answer
Doesn't work on my MacBook Pro, I am still seeing the .un~ files – gws Jun 1 '12 at 20:31
-1, this only applies to GNU ls, the -B option has a totally different meaning in OS X (or BSD ls for that matter). – slhck Jun 1 '12 at 20:34
@gws The question is if you would be fine with changing ls, i.e. compiling and aliasing to GNU ls, thus deviating from what comes with OS X. – slhck Jun 1 '12 at 20:41
@slhck I guess so, I typically use homebrew but it doesn't provide a GNU ls – gws Jun 1 '12 at 20:51

You must log in to answer this question.

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