exclude certain files in ls
Solution 1:
ls -I <filename>
-I = Ignore the filename, i.e., don't list the specified file.
To ignore more than one file add an -I before each filename.
ls -I file1 -I file2
To ignore files by their name extensions do the following, for example.
ls -I "*.jpg" -I "*.svg"
Solution 2:
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.
Solution 3:
ls --ignore={"*.jpg","*.png","*.svg"}