我刚看到bash中的一些代码,我不太明白.作为新手bash脚本,我不知道发生了什么.
echo ${0##/*}
echo ${0}
Run Code Online (Sandbox Code Playgroud)
我没有看到这两个命令的输出有什么不同(打印脚本名称).这#
只是一个评论吗?什么是/*
.如果是评论,为什么它不会干扰关闭}
括号?
谁能让我对这种语法有所了解?
我正在尝试使用Admin SDK Directory API,专门用于检索Users:get端点详细说明的用户信息.
我在oauthing时请求了以下权限
https://www.googleapis.com/auth/admin.directory.user
https://www.googleapis.com/auth/admin.directory.user.readonly
Run Code Online (Sandbox Code Playgroud)
但是,当我发出获取特定用户信息的请求时,我得到以下响应:
HTTP/1.1 403 Forbidden
Content-Type: application/json; charset=UTF-8
Date: Fri, 26 Jul 2013 18:25:29 GMT
Expires: Fri, 26 Jul 2013 18:25:29 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Transfer-Encoding: chunked
{
"error": {
"errors": [
{
"domain": "global",
"reason": "domainCannotUseApis",
"message": "Domain cannot use apis."
}
],
"code": 403,
"message": "Domain cannot use apis."
}
}
Run Code Online (Sandbox Code Playgroud)
我在API控制台中启用了Admin SDK .
我在Google Apps标准版(免费版)和Google Apps …
我在ssh上运行的一个脚本正在挂起,我在这个站点找到了一个解决方案:http: //www.snailbook.com/faq/background-jobs.auto.html
该站点通过将此添加到命令的末尾来解决问题:
xterm < /dev/null >& /dev/null &
Run Code Online (Sandbox Code Playgroud)
我想我知道它的作用是什么,但有人能帮忙解释一下吗?
第一部分:
# For stdin, read from /dev/null
< /dev/null
Run Code Online (Sandbox Code Playgroud)
第二部分:
>& /dev/null
Run Code Online (Sandbox Code Playgroud)
怎么>&
办?我已经看到2>&1
哪个是直接STDERR到STDOUT,但是当没有数字时,这是否意味着将所有内容重定向到/dev/null
?
我使用以下定义(改编自CSS2规范http://www.w3.org/TR/CSS21/cascade.html#specificity)
使用以下样式(我的计算在右侧):
.content {color: green;} /* a=0 b=0 c=1 d=0 -> 0,0,1,0 */
.content:hover {color: yellow;} /* a=0 b=0 c=2 d=0 -> 0,0,2,0 */
li {color: orange;} /* a=0 b=0 c=0 d=1 -> 0,0,0,1 */
li:first-line {color: pink;} /* a=0 b=0 c=0 d=2 -> 0,0,0,2 */
Run Code Online (Sandbox Code Playgroud)
和以下的HTML
<li class="content">The first line</li>
Run Code Online (Sandbox Code Playgroud)
当我在浏览器中打开它时,文本行是粉红色的.我以为它会是绿色的,在悬停时,它会是黄色的.我认为元素和伪元素(计算中的d)的重量小于类和伪类(计算中的c).
我对如何正确使用Python的子进程模块感到困惑,特别是check_output方法的第一个参数和shell
选项.查看下面交互式提示的输出.我将第一个参数作为列表传递,并且根据是否shell=True
设置,我得到不同的输出.有人可以解释为什么这是和输出的输出?
>>> import subprocess
>>> subprocess.check_output(["echo", "Hello World!"])
'Hello World!\n'
>>> subprocess.check_output(["echo", "Hello World!"], shell=True)
'\n'
Run Code Online (Sandbox Code Playgroud)
现在,当我将第一个参数作为简单字符串而不是列表传递时,我得到了这个讨厌的堆栈跟踪.为什么会这样?这里发生了什么?
>>> subprocess.check_output("echo Hello World!")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 537, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1228, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Run Code Online (Sandbox Code Playgroud)
但是,当我打开shell = True时,它会完美地运行:
>>> subprocess.check_output("echo Hello World!", shell=True)
'Hello …
Run Code Online (Sandbox Code Playgroud) bash ×2
linux ×2
css ×1
curly-braces ×1
python ×1
shell ×1
stdio ×1
subprocess ×1
syntax ×1
variables ×1