0

I need to execute "n" number of shell script using a master shell script (which have all the command to start other shell script). Since all other shell script are located in different location,can't give same path for all and I don't want to repeat "cd" command will be repeating for doing the same.

Apart from this, is there any way that i can start my shell script with both run and path given in one line?

eg:

"run command" "path" (for  file)
"run command" "path" (for  file1)

Kindly can anyone help on this.

4

1 回答 1

0

据我了解您的要求,它列出了以下目标:

  1. 您不想更改当前路径以在不同路径执行不同的脚本。

    解决方案:

    一个。您可以直接在命令行中使用完整的绝对路径运行脚本,而无需更改当前路径。

    湾。您可以使用 bash 命令、pushd 和 popd 在当前路径和其他位置之间频繁切换。

  2. 以一行中给出的运行和路径启动 shell 脚本。解决方案:

    这可以通过在两个命令之间使用分号来实现。例如:通过 1 行命令在当前目录以外的其他位置创建文件夹可以如下完成:

    cd /home/user ; mkdir testfolder

  3. 如果运行命令使用路径作为运行命令的输入参数。解决方案:

    这可以通过在执行每个命令之前使用 pushd 和 popd 命令来实现。

于 2013-10-21T09:40:13.690 回答