this is a done version of the previous thread. it concatenate all the arguments if they are not the same... however some case will make it a:a:b:a:b:c i try to change all the : into space and then uniq them out.... but the uniq is not working this way i guess... does anybody know why? thank you


for P
case $NP in
$P|$P:*|*:$P:*|*:$P) continue;;
*) NP="$NP:$P";;

second=`echo $NP | tr ':' ' ' | uniq -d `
echo $second

uniq works on lines, not characters on the same line.

so is there a way to eliminate the duplicates?

Print what you want on separate lines, then use uniq ?

if i run the program >foo a a:b a:b:c it should result in a:b:c .. the uniq didn't work in the program.. i already made it line by line..... ==''


for next
  case $result in 
       $next|$next:*|*:$next:*|*:$next) continue;;
       *) result="$result:$next";;
done                                ### at this point,, all the args are concatanated 

second=`echo $result | tr ' ' ':'`   #second step, turn all space into :

third=`echo "$second" | tr ':' '\12'`      #third step, turn all the : into new line

four=`echo "$third" | uniq `      ###supposed to uniq the previous step.. but not successful
                                                #using sort -u will do the trick.. but i do'nt want it sorted

IFS=" "
five=`echo "$four" | tr '\12' ' ' | tr ' ' ':'`        #change the new line back to : 
six=`echo "$five" | sed -e 's/^:/.:/' -e 's/::/:.:/' -e 's/:$/:./'`       
echo $six

just to echo myself... if at the beginnig i change everything separated by space , then
foo a a:b a:b:c will be "a a b a b c"

from there if i do the for loop and case above.. it will eliminate all the duplicates.... all figured out.. thanks for the replies...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.