cielle
1
May i know how can i pass up one of a location to a variable in script file with command in stead of hardcode?
saying in my script file:
maindir = "/opt/xSystem/config"
upOneDir = ?????
echo $upOneDir
I have to use command to pass "/opt/xSystem"
to variable upOneDir.
Please advise..
many thanks!
ningy
2
echo $mainder |awk -F/ '{gsub($NF,"");print}' |sed 's/.$//'
1 Like
cielle
3
hello Ningy,
thanks for your prompt reply.
I have tested your advice but still unable to get the thing work.
Please advice again.
Thank you
---------- Post updated at 04:34 AM ---------- Previous update was at 03:39 AM ----------
and why below only works for pwd.. but not other location..
dir1=$PWD
echo $dir1
higher_dir=$(cd ..
pwd)
echo higher_dir
this doesn't work when i replace the $PWD with "/opt/xSystem"
please advice..
Many thanks!
ningy
4
what output did u get when u ran my command above coz it worked for me..
cero
5
What shell do you use? In case of bash there are some nice string manipulation features:
maindir=/opt/xSystem/config
upOneDir=${maindir%/*}
echo $upOneDir
/opt/xSystem
1 Like
cielle
6
hello ningy..
it shows the blank.. hmm i did edit "maindir" from your code
thanks yea
---------- Post updated at 12:22 PM ---------- Previous update was at 12:21 PM ----------
hi cero,
thanks! it is working.