在这种情况下,我有一个由两个用户共享的脚本。一个用户使用bash,另一个用户使用zsh。我需要这个脚本使用bash或zsh,具体取决于登录用户。例如:
#!/bin/bash if user1
#!/bin/zsh if user2
如何才能真正实现这一目标呢?
更好的是,是否只有当特定用户正在执行脚本时,才会使用默认的shell?与…有关的东西:
if user1
then
#!/bin/bash
else
#!/bin/zsh
fi
我正在尝试为GitHub操作设置一个自定义操作,目前我所拥有的是: name: 'Install Dependencies'
inputs:
os:
description: 'The OS to fetch the dependencies for'
required: True
runs:
using: "composite"
steps:
- run: echo I am a test
shell: bash
if
所以我想从Python中调用一个shell脚本,使用
from subprocess import call
位于不同目录中具有相同扩展名的一组文件。这是我到目前为止所知道的:
for path, subdirs, files in os.walk(dir_path):
for name in files:
if name.endswith(".avg"):
os.chdir(os.path.join(path))
call(
这个脚本应该接受一组搜索词,并返回一个格式化的URL来搜索google。
$ ./google_search.sh albert einstein
https://www.google.com/search?q=albert+einstein
它可以很好地做到这一点,所以我决定添加一个选项,使用-s或-S标记搜索特定站点,或者忽略该站点。
$ ./google_search.sh -s wikipedia.org albert einstein
https://www.google.com/search?q=albert+einstein+site%3Awikipedia.org
这在您第一次
我想要编写一个脚本foo,它使用Bash或Perl使用与调用时完全相同的参数来调用bar。
现在,在perl中实现这一点的一个简单方法是
#!/bin/perl
my $args=join(' ', @ARGV);
`bar $args`;
但是,ARGV中的值已经由shell处理,因此如果我调用
foo "I wonder, \"does this work\""
bar会像这样被调用
bar I wonder "does this work"
我如何才能获得原始的命令行,这样我才能简单地逐字传递它?