[GRASS-user] g.mlist newline separator request
Patton, Eric
epatton at nrcan.gc.ca
Thu Apr 12 15:47:03 EDT 2007
I've noticed that g.mlist doesn't enter a newline after the last entry in a list, which used to be the case about a month ago:
~/coderepo >g.mlist pattern=Minas_Basin*
Minas_Basin_Jan16_2007_50m
Minas_Basin_Jan16_2007_50m_med3
Minas_Basin_Jan16_2007_50m_med3_shade
Minas_Basin_Jan16_2007_50m_med3_shade_comb
Minas_Basin_Jan16_2007_50m_shade
Minas_Basin_Jan16_2007_50m_shade_comb~/coderepo >
Consequently, any script that tries to get a count from g.mlist by piping to wc will get an incorrect count that will be off by one:
g.mlist pattern=Minas_Basin_Jan16_2007_50m | wc -l
0 (Should be 1)
g.mlist pattern=Minas_Basin* | wc -l
5 (Should be 6)
Would it be possible to get the final newline back? I have scripts that are broken now because a for loop never gets started when a check is done against the number of rasters matched:
MATCHES=`g.mlist pattern=${PATTERN} | wc -l`
# Abort if no matches are found.
if [ "$MATCHES" -eq 0 ] ; then
echo "$SCRIPT: No rasters matched the search pattern!"
exit 1
fi
~ Eric.
More information about the grass-user
mailing list