#!/bin/ksh #------------------------ fun_lookup () { #------------------------ i_max=$1 s_string=$2 i_cnt_lookup=0 while [[ ${i_cnt_lookup} -lt ${i_max} ]] do if [ "${s_path_array[$i_cnt_lookup]}" = "${s_string}" ] then return 1 fi let i_cnt_lookup=${i_cnt_lookup}+1 done return 0 } #------------------------------------------------------------------------------- # LOAD ARRAY #------------------------------------------------------------------------------- i_cnt_load=0 echo $PATH | tr ':' '\012' | while read s_read_dir do fun_lookup ${i_cnt_load} ${s_read_dir};s_rc=$? if [[ ${s_rc} -eq 0 ]] then s_path_array[${i_cnt_load}]=${s_read_dir} let i_cnt_load=${i_cnt_load}+1 fi done #------------------------------------------------------------------------------- # BUILD PATH #------------------------------------------------------------------------------- PATH=${s_path_array[0]} i_cnt_unload=1 while [[ ${i_cnt_unload} -lt ${#s_path_array[*]} ]] do # echo ${s_path_array[$i_cnt_unload]} PATH=${PATH}:${s_path_array[$i_cnt_unload]} let i_cnt_unload=${i_cnt_unload}+1 done echo ${PATH} exit