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:

  1. the . here matches char. in order match single dot is, have put \ in front of it, \..

  2. 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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -