It may be needed to view a file without displaying the numerous commentary lines attached to it (especially for the configuration files of your OS) and also considering removal of the empty lines.
- Making use of "egrep" (or "grep-E"):
- Lines starting with a hash (#) or the ending symbol dollar($) shall not be displayed.
- In this case the delimiter comment is not placed at the start of line but behind (space or tab), but you can change your expression as follows:
- Making use of sed
- Here it removes firstly, lines begining with a space or a pound sign, then removes all blank lines.
- You can improve the expression like:
- Making use of perl.
- Making use of perl will imply,considering the implementation of regex based on the engine used by the utilities.
- Using the NFA (Nondeterministic Finite Automation) engine, though slower than DFA (Deterministic Finite Automation) engine,allows you to refine and manage the regex to get a specific result:
Published by jak58
Latest update on August 26, 2010 at 08:10 AM by jak58.