Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell grep忽略第一个字符_Shell_Unix_Grep - Fatal编程技术网

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/'文件