syntax of ls --hide= and ls --ignore=

ls --hide and ls --ignore provides the possibility leave out files defined through regular expressions set after the --ignore= part. The latter makes sure that this option isn't turned off via -a, -A. The command's man and info page mention Regular Expressions.

Question: Which wildcards or Regular Expressions are supported in ls --hide= and ls --ignore=.

I found out that * $ ? seem to be supported, as well as POSIX Bracket Expressions. But this doesn't seem to work properly all the time and is more a game of trial and error for me. Did I miss something important here?


From the manual:

-I pattern, --ignore=pattern

In directories, ignore files whose names match the shell pattern (not regular expression) pattern. As in the shell, an initial . in a file name does not match a wildcard at the start of pattern. Sometimes it is useful to give this option several times. For example,

     $ ls --ignore='.??*' --ignore='.[^.]' --ignore='#*'

The first option ignores names of length 3 or more that start with ., the second ignores all two-character names that start with . except .., and the third ignores names that start with #.

You can use only shell glob patterns: * matches any number of characters, ? matches any one character, […] matches the characters within the brackets and \ quotes the next character. The character $ stands for itself (make sure it's within single quotes or preceded by a \ to protect it from shell expansion).

It uses POSIX.2 regex pattern format. See the re_format(7) man page for specific details.

Category: linux Time: 2013-06-15 Views: 1

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.196 (s). 12 q(s)