[:digit:]]字符bash等效



bash中使用的数字的alpha字符的正则标识符是什么?我的男人页面擦洗技能今天不是很好。

  • man bash并搜索"正则表达式"导致指向 REGEX(3(
  • 的段落
  • man 3 regex节"另请参见"指向 REGEX(7(
  • man 7 regex列出了可用的字符类,包括 digit ,以及您追求的内容, alpha

如果我正确地找到了你,则需要 character class的字母

[[:alpha:]]

,如果您正在寻找字母以外的其他任何内容,则

[^[:alpha:]] # well the ^ in the beginning of a range negates it

此[文章]是在正则读取的出色阅读。

要从文件或输入中获取有效的 IP地址,我将使用以下技术:

$ cat testfile.ip
Well this is a small para on IP addresses. Well to start with a string 
like 172.217.26.206 represents an IP address. Well, in this case it
is Google's IP. To put it short an IP like 192.168.0.16 is the token by
which a computer connected to internet is known to the outside wolrd. It 
is all numbers game! Really ! But as humans can't remember such crazy
numbers, some fellow devised a mechanism whereby we can call a computer 
by names like 'puppy' or 'vodoo'. This mechanism is called the DNS system 
whereby a computer is in charge of redirecting you to '192.168.0.34' in 
case you asked for 'vodoo' and '192.168.234.255' in case you asked for 
'puppy'. Well you've gateways as if you're going into some big cities. So 
you'll often here "You have the wrong gateway, mine is the right one 
which is 192.168.0.1." Well you have IPV6 addresses which are evern 
crazier numbers. Also, you do have wrong IP addresses like 
'288.134.43.22' and '999.1.0.255'. Aha ! You're in no man's land if you 
are assigned these IPS. Oh ! are you an alien? Sounds scary. Aww. Bye
$ grep -oP '[d]{0,3}.[d]{0,3}.[d]{0,3}.[d]{0,3}' testfile.ip |
awk -v FS="." '{for(i=1;i<=NF;i++){
if($i>=0 && $i<=255){continue;}else{next;}
}}1'
172.217.26.206
192.168.0.16
192.168.0.34
192.168.234.255
192.168.0.1

最新更新