I'm using Rmarkdown to show some bash code:
---
title: "Untitled"
author: "JPD"
date: "20 December 2016"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r gp.setup, engine= 'bash', eval=FALSE}
##Change names to remove dots
g.rename raster=gp_ortho.1,gp_ortho_1,gp_ortho.2,gp_ortho_2,\
gp_ortho.3,gp_ortho_3
##Group bands together
i.group --verbose group=gp_combo input=gp_ortho_1@gp1,gp_ortho_2@gp1,\
gp_ortho_3@gp1
```
However, when knitted to html, the g.rename line(s) mostly disappear. For comparison, the i.group command beneath is displayed correctly:
What is it about the g.rename line of code that is doing this? Is it the .
?
bash
treats dots/periods (.
) as a command to execute what follows, so instead of printing the literal characters it's looking for files called1
,2
, and3
.I don't have GRASS set up to work without starting a session, but my guess is if you do it your script correctly interprets the
g.rename
command and looks for the raster files you specify.I assume GRASS isn't set up in your Rmarkdown file so it's just printing the
g.rename...
characters then treating the.
as a file to execute so isn't printing what follows. To get it to print correctly, use something other than.
in your file names, set up your Rmarkdown session to understandg.rename
as a command, or escape the characters with\
: