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 :: commandAndExit cts 
Shell :: kill proccess 
Shell :: github terraform integration 
Shell :: how to stay opened ubuntu run in terminal 
Shell :: Revert Unstaged and Staged Changes in git command 
Shell :: cannot open display: localhost:0.0 
Shell :: split command in linux 
Shell :: install htop sudo add-apt-repository universe 
Shell :: usermod basic syntax 
Shell :: rsync kill 
Shell :: how to convert shell script to yaml file 
Shell :: how to make kali linux faster - To change swappiness value 
Shell :: how to use a addon installed after creaeting project unreal engine 
Shell :: How to point project to another remote repository git 
Shell :: Could not execute because the application was not found or a compatible .NET SDK is not installed. 
Shell :: exporting samtools to path 1.13 
Shell :: how to Login Database Server as the root user 
Shell :: simple youtube video downloader script install extension 
Shell :: powershell message all users on remote machine(s) 
Shell :: wsl how to mount make usb accessible 
Shell :: how to find inode of a file in linux 
Shell :: space as delimiter in cut command 
Shell :: see prerouting rules linux 
Shell :: gitattributes -diff 
Shell :: run zip command in powershell 
Shell :: cargo create 
Shell :: protocol error: filename does not match request 
Shell :: install fzf wsl 
Shell :: gitlab local runner run all jobs 
Shell :: wsl start windows program 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =