= FAQ!
  
image::ROOT:swarmlab.png[swarmlab,150,float=right]

[#How_to_get_the_path_of_current_script0]
xref:index.adoc#netflix[How to get the path of current script]




[#How_to_get_the_path_of_current_script]
[.text-right]
== How to get the path of current script  xref:index.adoc#How_to_get_the_path_of_current_script0[image:up-1.png[28,28,float=right]]

[source,bash]
----
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  TARGET="$(readlink "$SOURCE")"
  if [[ $TARGET == /* ]]; then
    SOURCE="$TARGET"
  else
    DIR="$( dirname "$SOURCE" )"
    SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
  fi
done

SRPATH="$( dirname "$SOURCE" )"
SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$SFPATH" != "$SRPATH" ]; then
  RDIR=$SRPATH    # relativ path directory
fi

#echo "full path file   $SOURCE"
#echo "full path dir    $SFPATH"
#echo "relativ path dir $SRPATH"

cwdir=$PWD
wdir=$SFPATH
cd $wdir

echo "current working directory,"
echo $cwdir
echo "dir of running program"
echo $wdir
----


	



