如何使用echo 编写非ASCII字符?是否有转义序列,例如\012或类似的东西?
我想使用以下方法将ASCII字符附加到文件:
echo ?? >> file
Run Code Online (Sandbox Code Playgroud) $i = 1
echo '
<p class="paragraph$i">
</p>
'
++i
Run Code Online (Sandbox Code Playgroud)
尝试将变量插入到回显的字符串中.上面的代码不起作用.如何将php变量迭代到echo字符串中?
我最近一直在玩ftrace来监控我系统的某些行为特征.我一直在处理通过一个小脚本打开/关闭跟踪.运行脚本后,我的系统会崩溃并自行重启.最初,我认为脚本本身可能存在错误,但我已经确定崩溃和重启是由于设置为function_graph echo时某些跟踪器到/ sys/kernel/debug/tracing/current_tracer的结果current_tracer.
也就是说,以下命令序列将产生崩溃/重启:
echo "function_graph" > /sys/kernel/debug/tracing/current_tracer
echo "function" > /sys/kernel/debug/tracing/current_tracer
Run Code Online (Sandbox Code Playgroud)
在上述echo语句导致崩溃后重启,我看到很多输出内容如下:
清除孤儿inode
<inode>
我试图通过将current_tracerfunction_graph中的值替换为C程序中的其他内容来重现此问题:
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
int openCurrentTracer()
{
int fd = open("/sys/kernel/debug/tracing/current_tracer", O_WRONLY);
if(fd < 0)
exit(1);
return fd;
}
int writeTracer(int fd, char* tracer)
{
if(write(fd, tracer, strlen(tracer)) != strlen(tracer)) {
printf("Failure writing %s\n", tracer);
return 0;
}
return 1;
}
int main(int argc, char* argv[])
{
int fd = openCurrentTracer(); …Run Code Online (Sandbox Code Playgroud) 这是https://serverfault.com/questions/102098/powershell-script-showing-commands-run的副本.我认为在这里提出这个问题会更合适.
我正在玩PowerShell脚本,他们工作得很好.但是,我想知道是否还有任何方法可以显示所有运行的命令,就像你自己手动输入它们一样.这与批处理文件中的"echo on"类似.我查看了PowerShell命令行参数cmdlet,但我没有找到任何明显的参数.
我试图让我的Makefile回显文本没有尾随的新行,但我无法.我正在体验OS X上的行为(在Linux上,一切都按预期工作).
a:
@echo -n "hello"
b:
@echo -n hello
c:
@/bin/echo -n "hello"
Run Code Online (Sandbox Code Playgroud)
输出:
$make a
-n hello
$make b
hello$make c
hello$
Run Code Online (Sandbox Code Playgroud)
换句话说,它make a被打破了.究竟发生了什么?是使用内置回声吗?很明显,双引号的存在改变了行为,但为什么呢?
正如@chepner所发现的那样,使用/bin/echomakefile中的完整路径正确理解-n标志.
我已经阅读了关于echo的手册页,它告诉我-e参数将允许转义字符(例如换行符的转义n)具有其特殊含义.当我输入命令
$ echo -e 'foo\nbar'
Run Code Online (Sandbox Code Playgroud)
进入一个交互式bash shell,我得到了预期的输出:
foo
bar
Run Code Online (Sandbox Code Playgroud)
但是,当我使用相同的命令(我已尝试将此命令字符作为测试用例的字符)时,我得到以下输出:
-e foo
bar
Run Code Online (Sandbox Code Playgroud)
这就好像echo将-e解释为一个参数(因为换行仍然显示),但它也将-e解释为一个回显的字符串.这里发生了什么?如何防止-e出现?
是否有可能在bash中回显退格?
就像是
echo $'stack\b'
Run Code Online (Sandbox Code Playgroud)
不应该输出stac?或者我错过了什么?
更具体地说,我想在以下方面使用它:
ls | wc -l; echo $'\b items'
Run Code Online (Sandbox Code Playgroud) 这是我用PHP脚本的html:
Run Code Online (Sandbox Code Playgroud)<html> <head> <title>Bob's Auto Parts</title> </head> <body> <h1>Bob's Auto Parts</h1> <table width = 100% > <tr> <?php echo "<td>This is working.</td>"; ?> </tr> </table> </body> </html>
为什么这个输出出现了; ?>.我希望它是'这是有用的'.只要.这是输出
鲍勃的汽车零件
鲍勃的汽车零件
这很有效.";?>
我知道我在这里做错了但却无法弄明白.提前致谢.
我只是想知道如何在单引号内回显变量(我使用单引号,因为字符串中有引号).
echo 'test text "here_is_some_test_text_$counter" "output"' >> ${FILE}
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激
这是我的阵列
<?php
$page['Home']='index.html';
$page['Service']='services.html';
?>
Run Code Online (Sandbox Code Playgroud)
我怎样才能像个人一样回应这样的事情
Home is at index.html
Run Code Online (Sandbox Code Playgroud)
又如何通过循环和回声全部做到这一点?