array values in a command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting array values in a command
# 1  
Old 06-21-2005
array values in a command

Smilie
I am a newbie to scripting so I am probably missing something but when this function runs it just returns blank lines, but if I surround the sed with a print it returns the full commands that can be excuted on the command line

ne_ip_change() {

set -A NE `$CAT /tmp/ne_list`

COUNT3=`$CAT /tmp/ne_list | wc -l`

z=0
while [ $z -lt $COUNT3 ]
do

$SED -n '/ManagedElementId string=\"${NE[$z]}\"/,/ipAddress ip_v4/p' $XML | grep ipAddress | cut -f2 -d'=' | cu
t -f1 -d'/'`

((z=z+1))
done
}
# 2  
Old 06-21-2005
I don't understand what you're saying. But this:
$SED -n '/ManagedElementId string=\"${NE[$z]}\"/,/ipAddress ip_v4/p'

looks like an attempt to reference a variable, but it is surrounded by single quotes. The shell will not expand a variable inside single quotes.
# 3  
Old 06-22-2005
use DOuble Quotes around Sed

Quote:
Originally Posted by eeisken
Smilie
I am a newbie to scripting so I am probably missing something but when this function runs it just returns blank lines, but if I surround the sed with a print it returns the full commands that can be excuted on the command line

ne_ip_change() {

set -A NE `$CAT /tmp/ne_list`

COUNT3=`$CAT /tmp/ne_list | wc -l`

z=0
while [ $z -lt $COUNT3 ]
do

$SED -n '/ManagedElementId string=\"${NE[$z]}\"/,/ipAddress ip_v4/p' $XML | grep ipAddress | cut -f2 -d'=' | cu
t -f1 -d'/'`

((z=z+1))
done
}

Use double quotes around sed
use echo "sed .........." to display the output
# 4  
Old 06-22-2005
Thanks guys,
worked a charm , sometimes you just can't see the wood for the trees
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Values in array are not able to be used one by one

hey,i stored the value of an sql query in an array and then tried to use that value in while loop. actually my array will have two or more values, then according to the values i have to display result. #!/bin/bash -xv val_1=$( sqlplus -s rte/rted1@rel75d1 << EOF set heading off select... (1 Reply)
Discussion started by: ramsavi
1 Replies

2. Red Hat

How to check for values in array?

i stored some values in array , then i traverse through the array and check for some values and if they exist then echo success. let us consider that in our array we stored values from an sql query like this #!/bin/bash declare -a arr arr=$( sqlplus -s rte/rted2@rel76d2 << EOF set... (1 Reply)
Discussion started by: ramsavi
1 Replies

3. Shell Programming and Scripting

PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array... (1 Reply)
Discussion started by: zeekblack
1 Replies

4. Shell Programming and Scripting

Store values in an Array

Hi all. Well, I have the next code: I need to make an array with the values I have in the bucle, but just don't get it... Question is, how can I store in an array that values, and how can I display them with echo? (8 Replies)
Discussion started by: crcbad
8 Replies

5. UNIX for Dummies Questions & Answers

Compare array values

# tail myprocesses.txt 178 processes at Tue Oct 21 14:33:01 IST 2008 16 MySQL processes at Tue Oct 21 14:33:01 IST 2008 175 processes at Tue Oct 21 14:36:01 IST 2008 60 MySQL processes at Tue Oct 21 14:36:01 IST 2008 192 processes at Tue Oct 21 14:39:01 IST 2008 64 MySQL processes at Tue Oct... (2 Replies)
Discussion started by: shantanuo
2 Replies

6. Shell Programming and Scripting

Assigning the values to an Array

hi every body, i donot know how to assign a array varible with a file see i having file more file property1 Name property2 Address the above two line are tab Space seperated between the property and its value i want to seperate it and assign to... (1 Reply)
Discussion started by: kkraja
1 Replies

7. Shell Programming and Scripting

Array values treated as one

I want each integer to be a value/element in the array, however the string is being treated as one. How can I stream these into distinct values? PSF6INDEX=`(snmpwalk -v 2c -c 'H0meru!es' ${SWITCH} .1.3.6.1.2.1.2.2.1.2 | grep 'GigabitEthernet' | sed 's/IF-MIB::ifDescr\.//g' | awk '{print $1}' |... (1 Reply)
Discussion started by: cytriesbash
1 Replies

8. Shell Programming and Scripting

How to use array values after the loop.

- I m retreving values from database and wish to use those values later in my shell script. I m placing these values in an array da_data but outside loop array is empty.Problem is its treating array as local inside loop hence array is empty outside loop. Plz go through the script and suggest how... (1 Reply)
Discussion started by: Devesh5683
1 Replies

9. UNIX for Dummies Questions & Answers

incorrect array values

I have a file with 2 lines and 3 filelds -bash-3.00$ cat del_old_files.cfg $DBA_WORK_DIR *sybdba* 30 $DBA_LOG_DIR *sybdba* 30 I have tried to set up arrays for each field (bash shell) declare -a dirArray=`cut -d' ' -f1 < del_old_files.cfg` declare -a nameArray=`cut -d' ' -f2 <... (6 Replies)
Discussion started by: jhillier
6 Replies

10. UNIX for Dummies Questions & Answers

Assigning values to an array

The way I've been using arrays currently have been: #!/bin/ksh set -A myArray myArray=value1 myArray=value2 myArray=value3 myArray=value4 Is there a way I can assign values to an array that will automatically place the value into the next element in the array like: myArray=value1... (4 Replies)
Discussion started by: yongho
4 Replies
Login or Register to Ask a Question