[GRASS-user] Renaming many files with one command

Vincent Bain bain at toraval.fr
Sat Mar 18 09:39:03 PDT 2017


Le samedi 18 mars 2017 à 09:13 -0700, Rich Shepard a écrit :
> On Sat, 18 Mar 2017, Vincent Bain wrote:

> > for i in `g.list type=vector pattern=open_h_*`;do g.rename vect=$i,`echo
> > $i | sed s/open_h_/blocked_h_/g`;done

>    It's close, but not complete:


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.


>    There needs to be a second argument to g.rename raster=from,to and the $1
> represents only the 'from' portion. There's no 'to' portion available from
> g.list.

the second member is given by `echo $i | sed s/open_h_/blocked_h_/g`


Good luck,
Vincent




More information about the grass-user mailing list