如何运行位于当前目录中文件的父目录中的脚本?

时间:2017-09-10 05:22:25

标签: bash

我的脚本进入一个包含大量用户的文件夹 /父母的/ usr /家/弗雷德 一旦它进入像fred这样的特定用户,它必须运行位于/ parent目录中的EX脚本 / parent可以在任何地方并命名任何我知道的是它在usr之上 然后,EX脚本使用EX编辑位于/ fred

中的文件

到目前为止我所拥有的

export default class CustomVideoBlot extends BlockEmbed {

 static create(url) {
    const node = super.create();
    const vidWrapper = <HTMLDivElement>document.createElement('div');
    // Set attributes on the iframe
    node.setAttribute('frameborder', '0');
    node.setAttribute('allowfullscreen', true);
    node.setAttribute('src', this.sanitize(url));
    // Set styles to the video wrapper
    Object.assign(vidWrapper.style, WRAPPER_ATTRIBUTES);
    // Append iframe as a child of the wrapper
    vidWrapper.appendChild(node);

    return vidWrapper;
  }
 }

编辑: 刚看了一下readlink,在cd进入文件夹之前尝试在.ex文件上使用readlink。

1 个答案:

答案 0 :(得分:0)

Readlink工作了,谢谢。

#!/bin/bash
replace=$(readlink -f replace.ex)
insert=$(readlink -f insert.ex)
echo $insert
echo $replace
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
          echo "replaced"
     else
          ex $L <$insert
          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
        echo "replaced"
    else 
        ex $P <$insert
        echo "inserted"

    fi; 
 fi;
 cd ..
 done 
相关问题