Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash get current path

echo $PWD
Comment

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 :: how to get token of a raw github file 
Shell :: bash store script output in variable 
Shell :: bash iterate over a variable range of numbers 
Shell :: import single table from mysql dump 
Shell :: error: refs/remotes/origin/PLAT-4366 does not point to a valid object! 
Shell :: curl certificate and password 
Shell :: composer install via cmd 
Shell :: gitignore all files and folders in only one folder 
Shell :: Git command to Change the Author Information Just for the Next Commit 
Shell :: error when i install sass 
Shell :: linux min 19.10 install virtualbox 
Shell :: bash change user 
Shell :: wordpress set tagline from cli 
Shell :: days between two dates in linux 
Shell :: docker build from github repository 
Shell :: make tarball backup of director 
Shell :: wget a file from bitbucket 
Shell :: android studio tortoisegit 
Shell :: git reset soft 
Shell :: list all commits for repo api github 
Shell :: https://repo.packagist.org could not be fully loaded 
Shell :: install tensorflow from source ubuntu 18.04 
Shell :: how to set gopath/bin linux 
Shell :: bash multiline comment 
Shell :: default gatsby typescript started 
Shell :: change keyboard layout linux 
Shell :: nvme cli 
Shell :: kali linux wsl 
Shell :: how to install velero on ubuntu 
Shell :: get shared mailbox powershell exchange 2010 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =