I am new to unix and want to know what does the below code does in bash shell script...
ScriptCMD=$0
cd ${ScriptCMD%/*}
ScriptPath=`pwd`
ScriptName=${ScriptCMD##*/}
ScriptNoExtName=${ScriptName%.*}
Please explain me what are the values of the above five variables.
Also I would be very thankfull if you can provide good documentation on these concepts.
Assume the script was called by : ScriptCMD=$0
The special variable $0 contains the name of the script specidied on the command line.
ScriptCMD=/home/user/script.ksh
cd ${ScriptCMD%/*}
The syntax ${var%pattern} substitute the variable $var and remove the smallest trailing part matching the pattern.
${ScriptCMD%/*}=/home/user
ScriptPath=`pwd`
Get the full script directory full path
ScriptPath=/home/user
ScriptName=${ScriptCMD##*/}
The syntax ${var##pattern} substitute the variable $var and remove the longuest leading part matching the pattern at the .
ScriptName=script.ksh
I think that there is a little bug when setting the script path if the script path is not specied on the command line but found in the PATH by the shell.
Assume:
The execution of the script gives
ScriptCMD=$0 -> script.ksh
cd ${ScriptCMD%/*} -> cd script.ksh -> Execution ERROR
ScriptPath=`pwd` -> /home/user -> Invalid value !
ScriptName=${ScriptCMD##*/} -> script.ksh
ScriptNoExtName=${ScriptName%.*} -> script
Hi ,
I have a code where i am using a infinite while loop . some thing like below
while
do
if
then
#go to line 20
fi
command 1;
command 2;
#line 20:
sleep 34; (5 Replies)
Hi,
I want to remove the following code from Source files (or replace the code with empty.) from all the source files in given directory.
finally {
if (null != hibernateSession && hibernateSession.isOpen()) {
//hibernateSession.close();
}
}
It would be great if the script has... (2 Replies)
hi all,
Can any 1 help me translate this korn shell code to C shell code :
email=$(grep "^$1" $folder/config_2.txt | awk '{print $2'})
In config_2.txt the content is :
which mean in korn shell , $1=groupname and $2=email address.
Now i need to write in C shell script,when i set the... (2 Replies)
Hi Guys,
I was just wondering if anybody can help me with this problem.
OK, how we can get a value back from PL/SQL Script (not stored procedure/function)
See the below example: (for example aaa.sh)
#!/bin/ksh
VALUE=`sqlplus -s user/password@test_id <<EOF
@xxx.sq
EOF`
echo $VALUE
... (7 Replies)