有人可以解释一下这是怎么回事吗?
-1 % 7 = 6 https://www.wolframalpha.com/input/?i=-1%257 ...但是
echo (-1 % 7)."\n"; // prints -1 WRONG
echo fmod(-1,7)."\n"; // prints -1 WRONG
Run Code Online (Sandbox Code Playgroud)
我还尝试了 php.net 中的这些示例,它们都正确返回。
echo (5 % 3)."\n"; // prints 2
echo (5 % -3)."\n"; // prints 2
echo (-5 % 3)."\n"; // prints -2
echo (-5 % -3)."\n"; // prints -2
Run Code Online (Sandbox Code Playgroud)
PHP 给了我一个我无法解释的结果 -1%7。它没有溢出 int 但我fmod还是尝试了,但我仍然遇到同样的问题(即看起来不是这个问题:php modulo 返回错误的结果)
我是Ubuntu和bash脚本的新手,但我刚刚创建runUpdates.sh并将其添加到我.profile运行它:
if [ -f "$HOME/bin/runUpdates.sh" ]; then
. "$HOME/bin/runUpdates.sh"
fi
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,我希望脚本像root运行一样运行(因为我不想输入我的sudo密码)
我发现了几个地方,我应该能够做到sudo chown root.root <my script>并且sudo chmod 4755 <my script>,当我运行它,它应该以root身份运行.但它不是......
这个脚本对我来说很好看.我错过了什么?-rwxr-xr-x 1 root root 851 Mar 23 21:14 runUpdates.sh*
你可以帮助我以root身份运行这个脚本中的命令吗?我真的不想更改sudors文件,我真的只想在root下运行这个脚本中的命令(如果可能的话).
#!/bin/sh
echo "user is ${USER}"
#check for updates
update=`cat /var/lib/update-notifier/updates-available | head -c 2 | tail -c 1`;
if [ "$update" = "0" ]; then
echo -e "No updates found.\n";
else
read -p "Do you wish to install updates? [yN] " …Run Code Online (Sandbox Code Playgroud) ZPL中有一种方法可以垂直居中吗?
我知道我可以使用^FO0,0^ASN,50^FB200,3,0,C,0^FD TEXT ^FS.但是,如果它足够短,我怎么能在第二行打印?