04-21-2010
Quote:
Originally Posted by
chebarbudo
[...]
Thanks radoulov for helping but your commands does not work with the sentence in a variable.
Actually I was suggesting to use an
array variable instead of
scalar variable ...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help.
echo $SH_VAR | command_line Syntax.
The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Discussion started by: jerardfjay
6 Replies
2. Shell Programming and Scripting
Hi,
I have a problem with expending variables when used in a for loop:
#!/bin/ksh
VAR1=aaa
VAR2=bbb
VAR3=ccc
for ITEM in VAR1 VAR2 VAR3
do
echo "${ITEM}"
done
This gives:
VAR1
VAR2
VAR3 (2 Replies)
Discussion started by: ejdv
2 Replies
3. Shell Programming and Scripting
Hi,
Again a little problem.
Do not understand good why an empty string is not detected.
Here is the program:
#!/bin/ksh
APR=`date | grep Apr | awk '{print $2$3}'`
MAY=`date | grep May | awk '{print $2$3}'`
JUN=`date | grep Jun | awk '{print $2$3}'`
echo "Variable Apr has value:... (6 Replies)
Discussion started by: ejdv
6 Replies
4. UNIX for Dummies Questions & Answers
Hello All,
This question is actually for the service console of VMware ESX 3.5 but is relevant to this forum I think. I have been advised to use the following commands:
for i in `find /vmfs/volumes/Test_VMFS/ -name "*.vmx"`
do
echo "$i"
#sed -i 's/scsi1:0.present =... (3 Replies)
Discussion started by: mronsman
3 Replies
5. Shell Programming and Scripting
Dear All,
i facing problem to use string having spaces in for loop..
file used for FOR LOOP
command.txt
rpm -t -v ttm -D -r RJLL -h YELP
rpm -t -v ttm -D -r RJLL -h ERRT
rpm -t -v ttm -D -r RJLL -h TYYE
rpm -t -v ttm -D -r RJLL -h POOL
CODE using for execute above command... (3 Replies)
Discussion started by: arvindng
3 Replies
6. Shell Programming and Scripting
Hello
I am having issues with a script I'm working on developing on a Solaris machine.
The script is intended to find out how many times a particular user (by given userid) has logged into the local system for more than one hour today.
Here is my while loop:
last $user | grep -v 'sshd'... (7 Replies)
Discussion started by: DaveRich
7 Replies
7. Shell Programming and Scripting
Hi Guys,
I'm trying to find all files with a particular extension and then loop some actions. The problem is that if the files have spaces in their names I get end up being each word as a separate result rather than the entire file.
ext=".txt"
out=".rtf"
for i in $( find "$1" -name "*$ext" );... (9 Replies)
Discussion started by: imonkey
9 Replies
8. Shell Programming and Scripting
Hello All,
Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....?
I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping
through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies
9. Shell Programming and Scripting
Hi Team!!
Please can anyone tell me why the following line does not work properly?
str3+=$str2
it seems that str3 variable does not keep its value in order to be concatenated in the next iteration! Thus when i print the result of the line above it returns the str2 value
What i want to do is to... (8 Replies)
Discussion started by: paladinaeon
8 Replies
10. UNIX for Dummies Questions & Answers
Hi,
input:
AAA|1
my script (the function is just an example):
gawk 'BEGIN{FS=OFS="|"}
function repeat(str, n, rep, i){
for(i=1; i<=n; i++)
rep=rep str
return rep
}
{
variable_1=repeat($1,$2)
variable_2=repeat($1,$2+1)
variable_3=repeat($1,$2+3)
... (5 Replies)
Discussion started by: beca123456
5 Replies