7.1. Matching a single character with a period

You can match any single character with a ‘.’ For example if we wanted to match a string that started with beg followed by any character and ended with an n,we could use beg.n. This would match begin and began amongst others.

We could also use it to match certain permissions from a ls -l command.

...x..x..x 

This would match all the execute permissions for owner, group and other:

drwxrwxrw-    – no match -rw-rw-rw-    – no match -rwx-rwxr-x   – match -rwx-r-x-r-x  – match 

Suppose you are filtering a text file, and you need to match all codes with an XC after the first four characters within a 10-character field. This would do it:

....XC.... 

What we have said in the above example is that the first ...

Get Linux and Unix Shell Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.