从 .bash_profile 获取目录中的所有文件 [英] source all files in a directory from .bash_profile

查看:23
本文介绍了从 .bash_profile 获取目录中的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要允许多个应用程序附加到系统变量(在本例中为 $PYTHONPATH).我正在考虑指定一个目录,每个应用程序都可以在其中添加一个模块(例如 .bash_profile_modulename).在 ~/.bash_profile 中尝试过类似的东西:

I need to allow several applications to append to a system variable ($PYTHONPATH in this case). I'm thinking of designating a directory where each app can add a module (e.g. .bash_profile_modulename). Tried something like this in ~/.bash_profile:

find /home/mike/ -name ".bash_profile_*" | while read FILE; do
source "$FILE"
done;

但它似乎不起作用.

推荐答案

不会

 for f in ~/.bash_profile_*; do source $f; done

够了吗?

编辑:额外的 ls ~/.bash_* 层简化为直接 bash globbing.

Edit: Extra layer of ls ~/.bash_* simplified to direct bash globbing.

这篇关于从 .bash_profile 获取目录中的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆