![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| double substitution | pppswing | Shell Programming and Scripting | 1 | 07-03-2008 09:10 AM |
| Bash: bad substitution problem...pls help! | xfouxs | UNIX for Dummies Questions & Answers | 1 | 11-23-2007 05:48 PM |
| how to read double consecutive space in filename for bash shell | james_falco | UNIX for Dummies Questions & Answers | 1 | 07-17-2007 05:32 PM |
| Double Substitution variables in ksh | xiamin | Shell Programming and Scripting | 19 | 05-23-2007 05:35 AM |
| double variable substitution | asal_email2 | UNIX for Dummies Questions & Answers | 1 | 06-14-2005 01:35 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How do I perform double substitution in bash?
#!/bin/bash
#set -x MAX=255 FILE=$1.dns_list #declare -a d_arr if [ -z "$1" ] then echo "Usage: `basename $0` network" echo " e.g.`basename $0` 1.1.1" exit fi echo "Remove file $FILE..." rm $FILE for (( i = 1; i < $MAX; i++ )) do PARSE=$(host $1.${i}) if [ $? = 0 ] then echo "$PARSE" " $1.$i" >> $FILE fi done cat $FILE | while read i do declare -a d_arr ln=`echo $i | awk '{printf $5 "\t : \t" $6}' |sed 's/\.XYZ\.com\.//g'` cnt=${#d_arr[@]} let c=$cnt d_arr[$c]=$ln # <<---<< I think I need double substitution for this stmt echo ${d_arr[$c]} done # For some reason the array does not exist cnt1=${#d_arr[@]} echo "The size of d_arr: $cnt1" echo "The array ${d_arr[@]}" exit Hi, How do I perform double substitution in bash? I try to write a bash script to list all the DNS entry from a subnet e.g. 192.168.1.0/24 and store the valid DNS entry into an array ${d_arr[]}, The variable d_arr[$c] works fine in while read i loop, but once the loop finished, array ${d_arr[]} is empty, I have tried he following: let ${d_arr[$c]}=$ln but get a syntax error. How do I get it store into an array for the duration when he program is still running? Thanks, -Fu |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|