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
Bash Shell脚本,grep有效IP解释_Bash_Shell_Grep - Fatal编程技术网

Bash Shell脚本,grep有效IP解释

Bash Shell脚本,grep有效IP解释,bash,shell,grep,Bash,Shell,Grep,我在网上找到了这段代码,我想知道它是如何工作的,你能帮我吗 grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" file.txt 我理解grep-E和-o,我也理解grep是一个有效的IP,但我不明白它是如

我在网上找到了这段代码,我想知道它是如何工作的,你能帮我吗

grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" file.txt
我理解grep-E和-o,我也理解grep是一个有效的IP,但我不明白它是如何做到的,你能解释代码的不同部分吗

25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?
这给出了250-255或200-249或0-199,因此它涵盖了IP地址0-255中允许的数字 然后\。给出了一个答案。
Total i构成了一个从0.0.0.0到255.255.255.255的IP

这个问题似乎离题了,因为它要求的是填鸭式的信息。稍微搜索一下就会找到答案。。。[