1
私のスクリプトはたくさんのユーザがいるフォルダを入力します /parent/usr/home/fred fredのような特定のユーザに入ると、/ parentディレクトリにあるEXスクリプトを実行する必要があります /parentはどこでもかまいませんそして何という名前の私が知っているすべては、それがEXスクリプトは、私が持っているもの 現在のディレクトリにあるファイルの親ディレクトリにあるスクリプトをどのように実行しますか?
/フレッドにあるファイルを編集するEXを使用していますUSR 上だで、これまでcd usr
cd home
FOLDERS=*
L=".bash_login"
P=".bash_profile"
for f in $FOLDERS
do
cd "$f"
if [ -f ".bash_login" ]
then
grep "/etc/runner" $L >/dev/null
if [ $? -eq 0 ]
then
#use swap ex
ex $L <replace.ex
echo "replaced"
else
ex $L <insert.ex
echo "inserted"
#use insert at end ex
fi;
else
grep "/etc/runner" $P >/dev/null
if [ $? -eq 0 ]
then
# use swap ex
ex $P <replace.ex
echo "replaced"
else
ex $P <insert.ex
echo "inserted"
fi;
fi;
cd ..
done
編集: ただ、READLINK読ん行きます.exファイルでreadlinkを試してから、cdをフォルダーに挿入してください。