bash - Linux - How to access/execute file from another folder and not changing folder -


i tried multiple scenarios these things more of headace. tried writing bash same, need change in same file need execute. can me same.

#!/bin/bash -p if [ $# -lt 1 ];     echo "no arguments provided"     exit 0 fi current_dir=`pwd` exec_dir=`dirname "$1"` filename="`basename $1`" cd $exec_dir cmd="./$filename ${@:2}" $cmd cd $current_dir 

i need 2 liner work same file need execute.

if script present in /opt/ , in /opt/dir/ can run script there --> ../script.sh run script previous folder , run in present folder


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -