[GRASS-user] Importing multiple files with r.in.xyz

Hanlie Pretorius hanlie.pretorius at gmail.com
Wed Aug 11 09:26:25 EDT 2010


2010/8/11, Nikos Alexandris <nikos.alexandris at felis.uni-freiburg.de>:
> Micha Silver <micha at arava.co.il>:
>> > Samber's method will surely work, but you might more simply try as
>> > follows:
>> >
>> > # start grass in a location which matches the txt file data
>> > # change to the directory where your txt files are, then do
>> > for infile in *.txt; do outrast=`basename ${infile} .txt`; r.in.xyz
>> > in=${infile} out=${outrast} fs=,; done
>
> Hanlie Pretorius wrote:
>> This works nicely, except that my input files have names like:
>> 3B42.000201.0.6.nc.lieb.txt
>> 3B42.000201.3.6.nc.lieb.txt
>>
>> and I want the output rasters to be named
>> 3B42.000201.0.6
>> 3B42.000201.3.6
>>
>> In fact, it would be best if they could be named:
>> 0201.0.6
>> 0201.3.6
>>
>> I'm struggling with this string manipulation in the shell scripting
>> language.
>
> Try the following (note the backticks in the beginning before "echo" and in
> the end as well):
>
> output=`echo "${infile}" | cut -d"." -f2,3,4 | sed 's/^00//'`

Yes, this worked :-) Thanks.

>
> Nikos
>


More information about the grass-user mailing list