是否有任何grep命令选项可以抑制模式文件中空行的影响?我更喜欢这个选项,而不是总是检查和过滤新生的模式文件。
以下是一个示例(在pattern_file
中,有一个空行):
$ cat pattern_file
APPLE
PEAR
$ cat file
Nothing
fruit
$ grep -f pattern_file file
Nothing
fruit
答案 0 :(得分:3)
忽略模式文件中的空行:
grep -f <(grep . pattern_file) file
答案 1 :(得分:1)
grep -v '^$'
这实际上抓住除换行之外的所有行。您可以将结果传递给grep,如下所示:grep -v '^$'| otherGrep
答案 2 :(得分:1)
关于 .ddsmoothmenu{
}
.ddsmoothmenu ul{
z-index:100;
margin: 0;
padding: 0;
list-style-type: none;
}
/*Top level list items*/
.ddsmoothmenu ul li{
position: relative;
display: inline;
float: left;
}
/*Top level menu link items style*/
.ddsmoothmenu ul li a {
display: block;
height: 46px;
width: 106px;
margin-right: 5px;
line-height: 35px;
padding-top: 10px;
font-size: 13px;
color: #FCFCC7;
text-align: center;
text-decoration: none;
font-weight: 400;
outline: none;
background: url(../images/templatemo_menu_item.jpg)
}
* html .ddsmoothmenu ul li a{ /*IE6 hack to get sub menu links to behave correctly*/
display: inline-block;
}
.ddsmoothmenu ul li a.selected, .ddsmoothmenu ul li a:hover { /*CSS class that's dynamically added to the currently active menu items' LI A element*/
color: #EB1765;
background: url(../images/templatemo_menu_hover2.png) no-repeat
}
/*1st sub level menu*/
.ddsmoothmenu ul li ul {
position: absolute;
width: 184px;
margin: 0 0 0 3px;
display: none; /*collapse all sub menus to begin with*/
visibility: hidden;
background: #F0E11A
}
/*Sub level menu list items (undo style from Top level List Items)*/
.ddsmoothmenu ul li ul li{
display: list-item;
float: none;
}
/*All subsequent sub menu levels vertical offset after 1st level sub menu */
.ddsmoothmenu ul li ul li ul{
top: 0;
}
/* Sub level menu links style */
.ddsmoothmenu ul li ul li a{
font-weight: 500;
width: 140px; /*width of sub menus*/
margin: 0 3px 0 1px;
height: 28px;
line-height: 28px;
padding: 5px 22px;
font-size: 11px;
text-align: left;
background: none;
color: #161AF7;
border-bottom: 1px solid #bab5b0
}
.ddsmoothmenu ul li ul li .last {
border-bottom: none;
}
.ddsmoothmenu ul li ul li a.selected, .ddsmoothmenu ul li ul li a:hover {
color: #EDEA15;
width: 139px;
padding-left: 25px;
background: #CF178E;
}
/* Holly Hack for IE \*/
* html .ddsmoothmenu{height: 1%;} /*Holly Hack for IE7 and below*/
/* ######### CSS classes applied to down and right arrow images ######### */
.downarrowclass{
position: absolute;
top: 12px;
right: 7px;
}
.rightarrowclass{
position: absolute;
top: 6px;
right: 5px;
}
/* ######### CSS for shadow added to sub menus ######### */
.ddshadow{
position: absolute;
: 0;
top: 0;
width: 0;
height: 0;
}
.toplevelshadow{ /*shadow opacity. Doesn't work in IE*/
opacity: 0.5;
}
/* menu */
选项:
空模式可以由pattern_file中的空行指定。
所以,这是一项功能,您应该delete empty lines,例如与-f
:
sed