Welcome to forum Raj, please use code tags as per forum rules for your commands/codes/Inputs used in your posts. Following is the link where you can go through from the forum rules. https://www.unix.com/misc.php?do=cfrules
Now coming to your question.
1st of all I think there is no need to use for loop you can check with following command. Be aware of using command which you have shown us because I think you don't want to kill all processes and command which you showed us can kill all processes if used correctly, I am a bit confuse here I guess if you are looking for a particular id of a process for example any java process, any script's process you can do following then.
If happy with above result use following then.
Now coming to your questions of using variables, here is some explaination for same.
i- ${PID}and $PIDseems to be same.
ii- `$PID` is having no meaning as either `PID` or $PID should do the trick to get value of variable PID.
iii- '$PID' this will simply print value $PID as echo will consider it as a simple text.
Please go through my post carefully, DONOT use commands blindly, read the post and try to understand things, get back to us if you have any questions on same.
Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
Thanks for the quick response.
I need to know can there be case where ${PID} and $PID be different.(No releation to the for loop).
What is the use of {} around the variable name. Does it affect the execution or the output.
The braces are required when parameter is a positional parameter with more than one digit, or when parameter is followed by a character which is not to be interpreted as part of its name.
For example
Last edited by Scrutinizer; 03-19-2015 at 02:28 AM..
This User Gave Thanks to Scrutinizer For This Post:
guys,
i would like to know what does the below does.
tr=`echo $bfile | cut -d"." -f4`
tr=${tr#TR}
i tried with assigning a value and executed second line. but after that also value of tr remains same.
thanks in advance .. (1 Reply)
Hi,
I have a shell script, In which i have variable "var1" and some perl command inside shell script.
export var1='coep -n rst-a2p-hinje.vci.all.com -c'
perl -pi -e 's/^/coep -n rst-a2p-hinje.vci.all.com -c /' command.txt
currently I am adding value of var1 in command.txt file by... (2 Replies)
Hi,
I need a help in setting scope of the variable. I want to use the below logic right before the "break" statement
if ; then
echo $header
echo $trailer
fi
But due the scope of the variable it is causing issues. I tried using "export" statement. But it changes the output completely
... (0 Replies)
Gurus,
I am trying to display a match (single character) from beginning of the line in a file using a variable.
I tried using sed ... not sure where am doing it wrong...
sed -n "/^\$variable/p" FileName.shor
sed -n "/^\${variable}/p" FileName.shBoth of the above are not working.....Thanks... (4 Replies)
Hi All
I am not able to understand the usage of d# in the below variable declaration.
FILE_LOC contains the directory path
And also help me to know about what will be saved in the variable j.
Thanks!!!
j=${d#${FILE_LOC}/} (2 Replies)
how can I find cpu usage memory usage swap usage and
I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times
my final destination is monitor process
logical volume usage above X % and number of Logical voluage above
can I not to... (3 Replies)
Hi I have to use a Environment variable and that variable has $ prefixed to its name like,
$var=/home/source/test/
i need to use the variable as i have show above. :confused:
Help requested..... Thanks in advance... (6 Replies)
Hi,
I have a .test file which has:
#!/bin/ksh
export TEST_FLAG=1
In the test1.ksh i have:
#!/bin/ksh
. .test
echo $TEST_FLAG
When i execute the test1.ksh its showing the value as 1.
But if i refer the same variable in another script, the value is not 1.
Basically, I need to have... (1 Reply)