Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

up vote 3 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
add comment

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  
-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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.