[GRASS-user] Renaming many files with one command
Vincent Bain
bain at toraval.fr
Sat Mar 18 11:12:01 PDT 2017
Weird... sorry, I just notice you meant to rename rasters, not vectors.
Anyway, here it works as well with rasters
GRASS 7.3.svn (local):~ > g.list rast
open_h_aze
open_h_qsd
GRASS 7.3.svn (local):~ > for i in `g.list type=raster
pattern=open_h_*`;do g.rename rast=$i,`echo $i | sed
s/open_h_/blocked_h_/g`;done
Rename raster <open_h_aze> to <blocked_h_aze>
Rename raster <open_h_qsd> to <blocked_h_qsd>
GRASS 7.3.svn (local):~ > g.list rast
blocked_h_aze
blocked_h_qsd
GRASS 7.3.svn (local):~ >
Is there something in the raster names suffixes that could be hurting
sed ? could you provide a g.list rast output ?
Anyone else may suggest an explanation?
Bye,
Vincent.
Le samedi 18 mars 2017 à 10:45 -0700, Rich Shepard a écrit :
> On Sat, 18 Mar 2017, Vincent Bain wrote:
>
> > Rich, this should work indeed (I just tested it down here, it works)... at
> > least if you have sed installed on your system. And also carefully mind
> > the reverse quotes(``) that enclose subprocesses.
>
> Vincent,
>
> Yes, sed is part of all linux distributions and I've used it many times in
> the past. However, it did not work here and I do use backticks to evaluate
> the string between them prior to handing the results to the preceeding
> command.
>
> Here's the verbatim command:
>
> for i in `g.list type=raster pattern=open_h_*`; do g.rename rast=$i,`echo
> $i | sed /open_h_/blocked_h_/g`; done
>
> (This all on one command line; split here to fit MUA width.)
>
> I don't see a syntax error yet it's not working here in grass-7.3.svn.
> Same error message as before for each file.
>
> Thanks,
>
> Rich
>
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
More information about the grass-user
mailing list