Bash - Path

Bash Liste Des Attaques Ovh


This article is about the path management in bash. ie /dir/childDir/fileName.

See also: Bash - pathname expansion (Filename expansion)

How to

get the name of the file

basename $path

from relative to absolute

MYPATH=$(readlink -f ${MYPATH})

is Absolute

if [[ "$PATH" = /* ]]; then
echo "absolute path";
echo "relative path";
case $PATH in
  /*) echo "absolute path" ;;
  *) echo "relative path" ;;

from Windows to Linux and vice-versa

cygpath -u path # from Windows to Linux
cygpath path # from Linux to Windows

File or Directory

if [[ -d ${ARG} ]]; then
    echo "${ARG} is a directory";
elif [[ -f ${ARG} ]]; then
    echo "${ARG} is a file";
    echo "${ARG} is not a path";
    exit 1;

Discover More
Bash Liste Des Attaques Ovh
Bash - Conditional Expression

A predicate or boolean expression is known in Bash as a Conditional Expression. It is a command that returns an exit status of 0 or 1. The conditional expression is part of the compound expression. ...
Undraw File Manager Re Ms29
File System - Path

in a file system. A file is identified by its path through the file system. A file path is a hierarchical URI where: scheme is the scheme that represents the file system such as: file (default)...

Share this page:
Follow us:
Task Runner