Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
file1
file2
file3
temp

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

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

1 Answer 1

up vote 8 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
1  
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 at 15:23
    
Thank you. ls -I "file*" also working. –  Sudheer Aug 18 at 15:42

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.