User Tools

Site Tools


bash:files:list_files_excluding_some_files

BASH - Files - List files excluding some files

Without enabled globbing, files can be excluded by the second command of this code section:

# List all files ending in .html.
ls | grep "\.html$"
 
# List all files not ending in .html.
ls | grep -v "\.html$"

If extended globbing is turned on:

printf "%s\n" *!(.html)

NOTE: globbing can be enabled by inserting setopt extendedglob in .bashrc

This should work:

ls path/*!(.html)
bash/files/list_files_excluding_some_files.txt · Last modified: 2021/01/26 12:21 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki