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
Post a Comment