OS X 10.6.5,BASH
当我运行这个:
echo $IP; echo of; echo $IPLINES
Run Code Online (Sandbox Code Playgroud)
我得到这个输出:
219.80.4.150:3128
of
1108
Run Code Online (Sandbox Code Playgroud)
当我运行这个:
echo $IP of $IPLINES
Run Code Online (Sandbox Code Playgroud)
我得到这个输出:
of 1108.150:3128
Run Code Online (Sandbox Code Playgroud)
我期望得到:
219.80.4.150:3128 of 1108
Run Code Online (Sandbox Code Playgroud)
什么会导致我得到的扭曲输出?
实际的脚本是这样的:
#!/bin/bash
IPLINES=`cat a.txt | wc -l | awk '{print $1}'`
if [ $IPLINES > 1 ]; then
LINE=`expr $RANDOM % $IPLINES + 1`
IP=`head -$LINE a.txt | tail -1`
sed -e "${LINE}d" -i .b a.txt
echo $IP of $IPLINES
fi
Run Code Online (Sandbox Code Playgroud) 当我输入时,echo $0我看到了-
我希望看到bash或一些文件名,如果我得到一个,这意味着什么"-"?
当var_dump时,我有一个类似于以下内容的数组:
array(3) { [0]=> array(3) { ["id"]=> string(1) "3" ["category"]=> string(5) "staff" ["num_posts"]=> string(1) "1" } [1]=> array(3) { ["id"]=> string(1) "1" ["category"]=> string(7) "general" ["num_posts"]=> string(1) "4" } [2]=> array(3) { ["id"]=> string(1) "2" ["category"]=> string(6) "events" ["num_posts"]=> string(1) "1" } }
Run Code Online (Sandbox Code Playgroud)
'如果数组不包含以下字符串,我需要回显一个值:'hello'
这怎么可能,我尝试过使用in_array,但没有成功.帮助赞赏.
标题几乎是自我解释的...
如何回显八进制字符串?
我试过了 :
<?php
echo '\047\131\145\141\162\040\072\040\047'.'<br>';
echo decoct('\047\131\145\141\162\040\072\040\047').'<br>';
echo decoct('047').decoct('131').decoct('145').decoct('141').decoct('162').decoct('040').decoct('072'),decoct('040').decoct('047').'<br>';
?>
Run Code Online (Sandbox Code Playgroud)
但没有什么对我有用....
我很确定这里需要一些小调整但是......哪一个?
谢谢!
当我看到这个问题时的后续问题How can I write and append using echo command to a file
我试图找到它应该已经得到答复,但显然它不存在或我找不到它。
我对在这个网站上发布问题真的很陌生(这是我的第一个!)
在命令行下,我知道使用 echo $? 给我退出代码。在gdb中,我使用“r”来运行程序,程序终止,那么gdb如何获取这个退出代码呢?gdb中有什么命令吗?
谢谢!
我正在创建一个bash脚本来自动执行某些命令,我在将错误检查写入同一文件时遇到了一些麻烦.
#!/bin/bash
touch ErrorLog.txt
bro-cut service < conn.log | sort | uniq -c > ProtocolHierarchy.txt
if [ $? -eq 0 ]; then
echo -e "OK Protocol Hierarchy Created\n" > ErrorLog.txt
else
echo -e "FAILED Creating Protocol Hierarchy\n" > ErrorLog.txt
fi
bro-cut id.orig_h < dns.log | sort | uniq -c > AllIPAddresses.txt
if [ $? -eq 0 ]; then
echo -e "OK Created all IP Addresses\n" > ErrorLog.txt
else
echo -e "FAILED Creating all IP Addresses\n" > ErrorLog.txt
fi
Run Code Online (Sandbox Code Playgroud)
目标是拥有一个我可以打开的文件,看到所有命令都工作或失败,目前文件看起来像这样
-e …Run Code Online (Sandbox Code Playgroud) 我正在运行 Echo 服务器和 Beyondcode (Pusher)。状态通道运行良好,我为其构建的消息传递也有效。现在我正在尝试让耳语也适用于打字状态,但没有运气。
发送悄悄话:
let channel = Echo.join('chat')
setTimeout( () => {
channel.whisper('typing', {
user: Laravel.user.id,
typing: true
})
}, 300)
Run Code Online (Sandbox Code Playgroud)
听耳语:
Echo.join('chat')
.listenForWhisper('typing', (e) => {
console.log(e)
});
Run Code Online (Sandbox Code Playgroud)
在我的回显服务器日志中,当我输入消息时:
testapp: connection id 332742863.966987392 received message:
{
"event":"client-typing",
"data":{
"user":2,
"typing":true
},
"channel":"presence-chat"
}
Run Code Online (Sandbox Code Playgroud)
广播频道(routes/channels.php)
Broadcast::channel('chat', function ($user) {
return [
'id' => $user->id,
'name' => $user->name
];
});
Run Code Online (Sandbox Code Playgroud)
连接 ID 332742863.966987392 是第二个用户(不是我输入消息的那个用户)。
但浏览器控制台中什么也没有出现。
我正在尝试使用预提交挂钩运行脚本。这是我的脚本:
构建脚本.sh
#! /bin/bash
echo "Stage 1: Preparing CMake configuration"
Run Code Online (Sandbox Code Playgroud)
.pre-commit-config.yaml
fail_fast: false
- repo: local
hooks:
- id: Generate build
name: Generate build
entry: sh build_script.sh
language: system
always_run: true
pass_filenames: false
Run Code Online (Sandbox Code Playgroud)
我可以看到,当我运行 command 时git commit -m "message",挂钩调用脚本Generate build并将通过。但是,我在终端上看不到回声。我想看看这条消息,"Stage 1: Preparing CMake configuration"。这个设置有什么问题吗?