Try this? It might a little slower...
Just for note...i havent tried this code yet...if u want to test, use a copy of card registry...Code:n=1; g=0; finish=0; declare -a dir; declare -a line; while test "$finish" != "1"; do get=`sed -n ${n}p $file`; # $file is ur card registry if test $(echo $get|grep "Directory = "); then let g++; dir[$g]=`echo $get|sed "s/Directory = //"`; line[$g]=$n; elif test ! "$get"; then finish=1; fi let n++ done ## modify the last records, $g is the latest... sed -e "${line[g]}s:Directory = ${dir[g]}:Directory = $new_dir:" $file > /tmp/temp.txt; # the $new_dir is the new directory u wanted to replace if cat /tmp/temp.txt; then mv /tmp/temp.txt $file; fi ## try to avoid an error ## done
In this code, we read the entire card registry...then assign it to array... So u can modify any Directory by number order... However, if u just want edit the "Directory = ekonsole" to "Directory = /mmc/mmca1/.system/QTDownLoad/ekonsole" just use sed...![]()



1Likes
Reply With Quote


