Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I would like to run ls and exclude certain files in the output.

When I run the following command, I get all files with each on one line:

$ ls -1

I would like to run this command in a way so it shows

$ ls -1 <insert magic here> temp
share|improve this question

2 Answers 2

up vote 16 down vote accepted
ls -I <filename>

-I = Ignores the file. It won't list the specified file.

To ignore more than one file add multiple -I before files.

ls -I file1 -I file2
share|improve this answer
If you use the long-form option --ignore you can extend that to glob patterns e.g. ls --ignore="file?" or ls --ignore="file*" –  steeldriver Aug 18 '14 at 15:23
Thank you. ls -I "file*" also working. –  Sudheer Aug 18 '14 at 15:42

For me if I use -I once, it works but if I use twice it doesn't. e.g: ls -I *.csv works.

But ls -I *.csv -I *.txt doesn't work and returns txt files instead.

--ignore did the trick for me. This is what I needed and worked.

ls -lhrt --ignore="*.gz" --ignore="*.1"

That will list me files from log folder where it exclude old backup logs.

share|improve this answer

Your Answer


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.