Skip to main content
IBM 
ShopSupportDownloads
IBM HomeProductsConsultingIndustriesNewsAbout IBM
IBM : developerWorks : Linux : Education - Tutorials
LPI certification 101 exam prep, Part 2
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
2. Regular expressions
  


Differing syntax page 8 of 11


It's important to note that the syntax inside square brackets is fundamentally different from that in other parts of the regular expression. For example, if you put a . inside square brackets, it allows the square brackets to match a literal ., just like the 1 and 2 in the examples above. In comparison, a literal . outside the square brackets is interpreted as a metacharacter unless prefixed by a \. We can take advantage of this fact to print a list of all lines in /etc/fstab that contain the literal string dev.hda by typing:


$ grep dev[.]hda /etc/fstab

Alternately, we could also type:


$ grep "dev\.hda" /etc/fstab

Neither regular expressions are likely to match any lines in your /etc/fstab file.


Main menuSection menuFeedbackPreviousNext
PrivacyLegalContact