I. Description
In some scenarios we want to filter out the empty lines and comment lines of old files, leaving the rows that produce the actual effect.
For example, there are a lot of blank lines and comment lines in the configuration sample file provided by Redis, and we want to filter out the configuration lines that produce the actual effect to form a new concise configuration file.
Second, the order
grep " ^$|# " old_file_name > New_file_name
grep--filtering commands
-e--using regular expressions to match
-v--culling of matching items (by default, filter matching items)
^--opening match
$--represents a blank line
|--or operations in a regular
#--#开头行
old_file_name--file to filter its contents
new_file_name--filtered content saved to the text pins XLR
Iii. examples
Reference:
https://www.zhihu.com/question/19795238
Linux filters empty lines in old files and comment lines remaining content to form a new file