我无法搜索特定的字符串,因为它们都非常相似,但我想要一些简单的方法来删除文件中的前4行.
它们都是可变长度的.我已经考虑过了perl,这一切看起来都比我想象的要难,但是如果可能的话,我想用Perl,AWK或shell命令来做.
有人有一个简单的方法吗?
我想知道是否可以在 Python 中使用匹配大小写来在字符串中进行匹配 - 即字符串是否包含匹配大小写。例子:
mystring = "xmas holidays"
match mystring:
case "holidays":
return true
case "workday":
return false
Run Code Online (Sandbox Code Playgroud)
我可以理解为什么它不会,因为这可能会同时匹配多个案例,但我想知道这是否可能。
我需要一些帮助制作这个脚本...到目前为止我觉得它应该看起来像这样(我倾向于使用AWK很多)
#!/usr/bin/perl -w
@filelist=(
file1,
file2,
file3
)
print ("<html>");
foreach $filelist {
print ("<table>";
print ("<td>"$filelist"</td>")
foreach [line in the file]
print ("<td>"$1, $2"</td>");
}
print ("</table>";
}
print ("</html>");
Run Code Online (Sandbox Code Playgroud)
所以我希望脚本转到每个文件,打印文件名,然后为每行打印一个中的两个strins <td>
我是在正确的轨道上吗?
另外,我意识到我写的AWK需要几个IF语句 - 我相信它应该是这样的
while(<F_IN>) {
if ($1>=2) {
print "<td class=\"green\" title=\""$1,$2"\">"
}
if ($1>=1) {
print "<td class=\"amber\" title=\""$1,$2"\">"
}
if ($1>=0) {
print "<td class=\"red\" title=\""$1,$2"\">"
}
Run Code Online (Sandbox Code Playgroud)