Mik*_*ter 43 bash shell scripting
我需要允许几个应用程序附加到系统变量(在这种情况下为$ PYTHONPATH).我正在考虑指定一个目录,每个应用程序都可以添加一个模块(例如.bash_profile_modulename).在〜/ .bash_profile中尝试过类似的东西:
find /home/mike/ -name ".bash_profile_*" | while read FILE; do
source "$FILE"
done;
Run Code Online (Sandbox Code Playgroud)
但它似乎不起作用.
Dir*_*tel 72
岂不
for f in ~/.bash_profile_*; do source $f; done
Run Code Online (Sandbox Code Playgroud)
够了吗?
编辑:额外的一层ls ~/.bash_*
简化直接bash globbing.
Cas*_*bel 17
我同意上面的丹尼斯; 你的解决方案应该工作(虽然"完成"之后的分号不应该是必要的).但是,您也可以使用for循环
for f in /path/to/dir*; do
. $f
done
Run Code Online (Sandbox Code Playgroud)
没有必要使用命令替换ls,就像在Dirk的回答中那样.例如,这是用于获取/etc/bash_completion
其他bash完成脚本的机制/etc/bash_completion.d
gaR*_*Rex 17
Oneliner(仅适用于bash/zsh):
source <(cat *)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
28061 次 |
最近记录: |