我正在创建一个连接到服务器并将输出转储到临时文件的脚本。我想在脚本中使用 sed 从临时文件中获取特定信息。输出总是有 80 个字符的虚线,然后是我想要的信息,然后是 Disconnected 语句。
如果它只是一行,我已经得到了一个正则表达式,问题是我如何对换行符进行分组?
正则表达式
-\{80\}[\r\n]*\(.*\)[\r\n]\{4\}Disconnected
Run Code Online (Sandbox Code Playgroud)
文件
...
--------------------------------------------------------------------------------
The information that I want to get can be a single line or multiple lines.
Another line to grab.
And this should be caught as well.
Disconnected ...
Run Code Online (Sandbox Code Playgroud)
期望输出
The information that I want to get can be a single line or multiple lines.
Another line to grab.
And this should be caught as well.
Run Code Online (Sandbox Code Playgroud) 我有两个 NTP 层 3 服务器正在运行,并且想要创建一个简单的检查,我可以判断其中任何一个服务器的时间是否漂移并警告它没有与公共层 2 服务器正确同步。
我的第一个想法是从多个第 2 层服务器中提取时间,并将该时间与我的 ntp 服务器发送的时间进行比较。然后提醒漂移是否超过 X delta。
是否有更标准的方法或更好的方法来验证 NTP 服务器发送的时间是否正确?
我有一个要使用 ddclient 更新的子域。我将 ddclient 配置为从 dyndns 获取 IP,但它没有更新 namecheap 上的子域。他们说使用 yourdomain.com 作为登录名而不是我的实际域。
有没有人能够使用 ddclient 更新 namecheap DNS?
我正在使用 ddclient 3.7.3 运行 CentOS 6.2。
当我运行 ddclient 时,我得到以下信息。
CONNECT: checkip.dyndns.org
CONNECTED: using HTTP
SENDING: GET / HTTP/1.0
SENDING: Host: checkip.dyndns.org
SENDING: User-Agent: ddclient/3.7.3
SENDING: Connection: close
SENDING:
RECEIVE: HTTP/1.1 200 OK
RECEIVE: Content-Type: text/html
RECEIVE: Server: DynDNS-CheckIP/1.0
RECEIVE: Connection: close
RECEIVE: Cache-Control: no-cache
RECEIVE: Pragma: no-cache
RECEIVE: Content-Length: 106
RECEIVE:
RECEIVE: <html><head><title>Current IP Check</title></head><body>Current IP Address: IPADD</body></html>
Use of uninitialized value in …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个 bash 脚本,该脚本将使用 egrep 从文件中 grep 行。我已经创建了应该对我想要的信息进行分组的正则表达式,问题是试图获得输出。我一直在使用以下命令对其进行测试,但运行时没有打印任何内容。如何打印 -{80} 和 Disconnected 之间的多行?
egrep -E "^-{80}$\r?\n?([:ascii:]*)Disconnected from Server" testing.txt
Run Code Online (Sandbox Code Playgroud)
文件:testing.txt
Connected to the server: name here
Some header text.
More text to go though...
--------------------------------------------------------------------------------
The information that I want, would be in here;
Including this line as well #$
and this one.
Disconnected from Server...
Run Code Online (Sandbox Code Playgroud)