![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| xlC compilation error when dealing with operator overloading | luop0812 | AIX | 1 | 04-09-2008 04:09 PM |
| perl: When dealing with files that do not exist | joeyg | Shell Programming and Scripting | 2 | 02-20-2008 05:09 PM |
| tsch script problem (dealing with sed) | csnewbie84 | Shell Programming and Scripting | 10 | 05-02-2007 10:51 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Help in dealing with arra
I am readinga file lin by line and based craeting a arry of unique elemenst from the second column of the line. However when i coem out of the while loop my array becomes empty , can eny one tell me what I would be doing wrong
#!/bin/bash logfile="./mylog.dat" begin=100 end="$(( $begin + 1000 ))!d" index=0 Isthere=0 ENGINES="" sed "$begin, $end" $logfile | while read line do i=`echo $line | awk -F "," '{print $2}'` Isthere=0 for item in "${ENGINES[@]}" ; do if [ "$i" = "$item" ] ; then echo "Aleady there " Isthere=1 break fi done if [ "$Isthere" -eq 0 ] ; then echo "adding $Isthere" ENGINES[$index]=`expr $i` index=$(( $index + 1)) fi # echo $line done echo $index ${#ENGINES[@]} # howe ever at this point array is empty for i in "${ENGINES[@]}" ; do echo $i done |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|