Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash get path of script

SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
Comment

bash get path of command

type -a <command>
Comment

bash find path of current script

#!/usr/bin/env bash

SOURCE="${BASH_SOURCE[0]:-$0}";
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  DIR="$( cd -P "$( dirname -- "$SOURCE"; )" &> /dev/null && pwd 2> /dev/null; )";
  SOURCE="$( readlink -- "$SOURCE"; )";
  [[ $SOURCE != /* ]] && SOURCE="${DIR}/${SOURCE}"; # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname -- "$SOURCE"; )" &> /dev/null && pwd 2> /dev/null; )";
Comment

PREVIOUS NEXT
Code Example
Shell :: remove folder ubuntu 
Shell :: change regolith terminal 
Shell :: vagrant run paralel 
Shell :: how to run spigot server using bat 
Shell :: linux update command 
Shell :: linux mv all folder to previous folder 
Shell :: how to install tar.xz file on ubuntu 
Shell :: change current branch git 
Shell :: youtube dl download linux 
Shell :: docker remove unused 
Shell :: Required Windows feature(s) not enabled : Hyper-V and Containers 
Shell :: install composer package from github 
Shell :: homebrew not in path on ubuntu 
Shell :: The framework needs the following extension(s) installed and loaded: intl. at SYSTEMPATHCodeIgniter.php:219 
Shell :: command get full history terminal mac 
Shell :: gcc for macos 
Shell :: Push a New Branch To Remote Repository in git command 
Shell :: powershell get-childitem 
Shell :: how to install mongodb server in ubuntu 
Shell :: ionic cordova generate component 
Shell :: add extra cygwin packages 
Shell :: assign contents of file to variable bash 
Shell :: git find current head 
Shell :: dump database docker 
Shell :: revert last merge git 
Shell :: dash bootstrap import 
Shell :: ionic Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation. 
Shell :: git clone tag 
Shell :: su: failed to execute /bin/bash: Resource temporarily unavailable 
Shell :: bash copy file 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =