a=$$


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting a=$$
# 1  
Old 05-21-2010
a=$$

just tell me wat variable =$$ will do in a shell script
Code:
#!/bin/ksh
a=$$
echo $a


this code is giving output as
Code:
ddwh01-TEST ./Orange_Internal_Training> sh a1.sh
802874

if put some parameter then
Code:
ddwh01-TEST ./Orange_Internal_Training> sh a1.sh 1 2
618548

ddwh01-TEST ./Orange_Internal_Training> sh a1.sh 1
315612


Last edited by Scott; 05-21-2010 at 04:19 AM.. Reason: Please use code tags
# 2  
Old 05-21-2010
$$ is process ID of your script Smilie
This User Gave Thanks to ygemici For This Post:
# 3  
Old 05-21-2010
here are some default variable related to shell for informational purpose.

Code:
$#  	Number of arguments to script
$* 	Arguments to script
$@ 	Original arguments to script
$- 	Flags passed to shell
$? 	Status of previous command
$$ 	Process identification number
$! 	PID of last background job
$_	Last argument of the last command


anything missed out?
# 4  
Old 05-21-2010
Code:
$- Flags passed to shell

could you please explain about this special parameter .
# 5  
Old 05-21-2010
This tells, with which flags, the script is invokes.
-v, -x etc.

Code:
#!/bin/sh -v
echo "flags are $-"

# 6  
Old 05-21-2010
Quote:
Originally Posted by anchal_khare
This tells, with which flags, the script is invokes.
-v, -x etc.
Code:
#!/bin/sh -v
echo "flags are $-"

showing output
Code:
flags are himBH

Smilieit has suppose to give the result v

Thanks
Posix..
# 7  
Old 05-21-2010
this is what i am getting:

Code:
$ ./x5
echo "flag is $-"
+ echo flag is vxh
flag is vxh
$ cat x5
#!/usr/bin/ksh
set -vx
echo "flag is $-"

with your input, I am getting:

Code:
$ ./x5
echo "flag is $-"
flag is vh
$ cat x5
#!/usr/bin/sh
set -v
echo "flag is $-"

I think "h" occurs in all cases. I am not sure for what "h" stands for.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question