首页 > 解决方案 > 如何在脚本中运行 .profile

问题描述

当我在脚本下面运行时,我必须先 SU 并在脚本中运行配置文件。配置文件正在向终端提供日志,参数在 profiel 中解析或不解析下一行。提前谢谢

if [ $owner = "user1" ]
then
    su -c " . ~/.profile; cd $LOG_DOR; cat $job.log" - user1
else
    echo "$owner not found"
fi

标签: linuxbashunix

解决方案


要将文件读入当前 shell,请使用source

source ~/.profile

推荐阅读