I was trying to develop a simple bash script where one positional parameter is used. But for no reason the parameter is empty. The bash script is given bellow.
#!/bin/bash
ulimit -s hard
if [ "$1" != "" ]; then
echo "Positional parameter 1 contains something"
else
echo "Positional parameter 1 is empty"
fi
root="$(dirname "$(readlink -f "$1")")"
dir="$(basename "$(readlink -f "$1")")"
path=$root/$dir
echo $path
While I was running the script file in the following way, it shows empty strings.
I was using bash -c command since i need to run the bash script from a java code using ProcessBuilder Class.
I know very little about bash scripting and I tried in more simpler way like:
root=`dirname $1`
dir=`basename $1`
path=$root/$dir
But the result is all the same.