O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required