Shell grep忽略第一个字符
如果我有一堆行,它们有:Shell grep忽略第一个字符,shell,unix,grep,Shell,Unix,Grep,如果我有一堆行,它们有: //mainHtml = "https:// mainHtml = "https: //https:www.google.com public String ydmlHtml = "https://remando aasdfa dsfadsf a asdfasd fasd fsdafsdaf 现在我只想grep那些有“https:”的行,但它们不应该以“/”开头 到目前为止,我已经: cat $javaFile | grep -e '\^\/ *https:*\'
//mainHtml = "https://
mainHtml = "https:
//https:www.google.com
public String ydmlHtml = "https://remando
aasdfa dsfadsf a asdfasd fasd fsdafsdaf
现在我只想grep那些有“https:”的行,但它们不应该以“/”开头
到目前为止,我已经:
cat $javaFile | grep -e '\^\/ *https:*\'
其中$javaFile是我要查找单词的文件。
我的输出是空白的。
请帮助:)分两步进行:
grep -v '^//' | grep 'https:'
删除以grep-v'^/'
/
获取包含grep'https:'
http:
grep -v '^//' | grep 'https:'
删除以grep-v'^/'
/
获取包含grep'https:'
http:
grep -v '^//' | grep 'https:'
删除以grep-v'^/'
/
获取包含grep'https:'
http:
grep -v '^//' | grep 'https:'
删除以grep-v'^/'
/
获取包含grep'https:'
http:
-E
选项来使用ERE或扩展正则表达式
grep -E '^[^/]{2}.*https' file
使用您的示例数据:
$ cat file
//mainHtml = "https://
mainHtml = "https:
//https:www.google.com
public String ydmlHtml = "https://remando
aasdfa dsfadsf a asdfasd fasd fsdafsdaf
您也可以选择在不使用-E
选项的情况下编写它,方法是:
grep '^[^/][^/].*https' file
可以使用character类对行的开头求反。我们使用
-E
选项来使用ERE或扩展正则表达式
grep -E '^[^/]{2}.*https' file
使用您的示例数据:
$ cat file
//mainHtml = "https://
mainHtml = "https:
//https:www.google.com
public String ydmlHtml = "https://remando
aasdfa dsfadsf a asdfasd fasd fsdafsdaf
您也可以选择在不使用-E
选项的情况下编写它,方法是:
grep '^[^/][^/].*https' file
可以使用character类对行的开头求反。我们使用
-E
选项来使用ERE或扩展正则表达式
grep -E '^[^/]{2}.*https' file
使用您的示例数据:
$ cat file
//mainHtml = "https://
mainHtml = "https:
//https:www.google.com
public String ydmlHtml = "https://remando
aasdfa dsfadsf a asdfasd fasd fsdafsdaf
您也可以选择在不使用-E
选项的情况下编写它,方法是:
grep '^[^/][^/].*https' file
可以使用character类对行的开头求反。我们使用
-E
选项来使用ERE或扩展正则表达式
grep -E '^[^/]{2}.*https' file
使用您的示例数据:
$ cat file
//mainHtml = "https://
mainHtml = "https:
//https:www.google.com
public String ydmlHtml = "https://remando
aasdfa dsfadsf a asdfasd fasd fsdafsdaf
您也可以选择在不使用-E
选项的情况下编写它,方法是:
grep '^[^/][^/].*https' file
如果我想忽略以//开头但仍有https的行,则必须使用管道字符将它们结合起来:
grep-v'^/'| grep'https:'
。否则,您可以使用@jaypal的解决方案,它看起来更好@jaypal抱歉,budd,不记得了,但很快会检查:)如果我想忽略以//开头的行,并且仍然有https,则必须使用管道字符将两者结合起来:grep-v'^/'|grep'https:'
。否则,您可以使用@jaypal的解决方案,它看起来更好@jaypal抱歉,budd,不记得了,但很快会检查:)如果我想忽略以//开头的行,并且仍然有https,则必须使用管道字符将两者结合起来:grep-v'^/'|grep'https:'
。否则,您可以使用@jaypal的解决方案,它看起来更好@jaypal抱歉,budd,不记得了,但很快会检查:)如果我想忽略以//开头的行,并且仍然有https,则必须使用管道字符将两者结合起来:grep-v'^/'|grep'https:'
。否则,您可以使用@jaypal的解决方案,它看起来更好@jaypal抱歉budd,不记得了,但很快会检查:)你也可以使用awk'/^[/][/].*https/'文件
您也可以使用awk'/^[/][/].*https/'文件
您也可以使用awk'/^[/][/].*https/'文件
您也可以使用awk'/^[/][/].*https/'文件