有没有办法打印 ASCII 字符 '??? ' 和 '???' 使用 bash 或 perl 脚本?我希望它与“树”的输出完全一样。
[root@localhost www]# tree -L 1
.
??? cgi-bin
??? error
??? html
??? icons
Run Code Online (Sandbox Code Playgroud) 我有一个启动 xterm 并转储 uart 日志的应用程序。我能够看到它启动并在 GUI 中转储日志。但是,使用远程会话,我希望 xterm 输出作为后台进程在某处运行,以便我可以在单个终端内来回切换。
使用图形用户界面
使用远程终端 (SSH)
$ xterm
xterm: Xt error: Can't open display: :0
Run Code Online (Sandbox Code Playgroud)
我试图做类似的事情,但没有成功 -
alias xterm="/bin/bash -c"
Run Code Online (Sandbox Code Playgroud)
我也不想X forwarding在我的本地机器上有并启动一个窗口。
我有一个运行PHP/HTML页面的Linux Web服务器.
我需要保存一个必须解释为数组的输出 -
exec($instruction);
Run Code Online (Sandbox Code Playgroud)
输出的位置
1 2 5 7 0 5 3 4
Run Code Online (Sandbox Code Playgroud)
我必须能够调出数组中的特定元素
echo $result[4]
Run Code Online (Sandbox Code Playgroud)
到目前为止,以下尝试都没有成功
$result =exec($instruction);
or
$result = array(exec($instruction));
Run Code Online (Sandbox Code Playgroud)
更新,到目前为止我试过这个 -
$result = shell_exec($instruction);
$out = explode(" ",$result);
Run Code Online (Sandbox Code Playgroud)
我得到了预期的输出,但为什么exxplode()不返回单个元素?
Array ( [0] => 1 1 1 2 1 2 0 0 1 1 )
Run Code Online (Sandbox Code Playgroud) 我无法将grep中使用的Perl正则表达式转换为perl语法
#/bin/bash
string="Last logical block address=936640511 (0x37d3ffff), Number of blocks=936640512"
echo $string | grep -Po '(?<=blocks=)[^$]*'
Run Code Online (Sandbox Code Playgroud)
用perl,我无法成功
#!/usr/bin/perl
my $string="Last logical block address=936640511 (0x37d3ffff), Number of blocks=936640512";
my ($blocks) = $string =~ m/(?<=blocks=)[^$]*/;
print $blocks;
Run Code Online (Sandbox Code Playgroud)
如果我使用正确的正则表达式,请建议.