linux - Regex getting dot files except the current and parent dictionaries -
i'm reading book "how linux works". author gave following regular expressions can dot files except current , parent directories. (page 21)
.??* .[^.]*
if dot files exist in directory both work. when no dot files exist first 1 work.
i can't understand them. can describe me?
$ ls -a . .. .hiding $ ls -a | grep .??* .hiding $ ls -a | grep .[^.]* .hiding $ mv .hiding hiding $ ls -a | grep .??* $ ls -a | grep .[^.]* . .. hiding
the first not make sense, not work me, , cannot find documentation ??
either.
regardless, there 2 problems both of these regexes:
the
.
here matches char. in order match single dot is, have put\
in front of it,\.
.the whole expression can match anywhere in line. have assert matching starts @ beginning. start
^
.
try: ls -a | grep '^\.[^.]'
means: starting @ beginning of line, find single dot. char not listed (negation done second ^
here) between brackets, not literal dot.
in brackets don't have use \
, although can.
Comments
Post a Comment