Using ack to effectively search and RStudio project directory
3
votes
0
answers
189
views
I'm interested in running
ack
search on a RStudio project directory that mostly contains *.R
script files but also some project files and often *.git
files.
# Directory
The project folder structure created from a default Shiny application:
$ tree
.
├── SomeNosense.Rproj
├── server.R
└── ui.R
# Search
Given this I'm interested in running a simple search for a word ***old*** across the ***.R
** files only. *The sample shiny app created as a defult projects has some strings where the word **old** is mentioned*.
ack -i -rr 'Old'
I'm getting results that do not match what should correspond to ack --help-types
, which shows:
--[no]rr .R
## Results
whereas
my results for this command are very messy:
.Rproj.user/38B87E11/sdb/s-FEC4716C/28624A5C
7: "folds" : "",
.Rproj.user/38B87E11/sdb/s-FEC4716C/8A580C19
3: "contents" : "\n# This is the user-interface definition of a Shiny web application.\n# You can find out more about building applications with Shiny here:\n#\n# http://shiny.rstudio.com\n#\n\nlibrary(shiny)\n\nshinyUI(fluidPage(\n\n # Application title\n titlePanel(\"Old Faithful Geyser Data\"),\n\n # Sidebar with a slider input for number of bins\n sidebarLayout(\n sidebarPanel(\n sliderInput(\"bins\",\n \"Number of bins:\",\n min = 1,\n max = 50,\n value = 30)\n ),\n\n # Show a plot of the generated distribution\n mainPanel(\n plotOutput(\"distPlot\")\n )\n )\n))\n",
7: "folds" : "",
ui.R
13: titlePanel("Old Faithful Geyser Data"),
# Desired results
Desired results can be achieved with grep
:
me-547/47:SomeNosense$ grep -r -i 'old' ~/Documents/SomeNosense/*.R
/Users/me/Documents/SomeNosense/ui.R: titlePanel("Old Faithful Geyser Data"),
# Question
What is wrong with my [tag:ack] command that I'm not getting the same results?
---
The ag
also seems to be returning more accurate results:
me-552/52:SomeNosense$ ag -rr -i 'old'
ui.R
13: titlePanel("Old Faithful Geyser Data"),
me-553/53:SomeNosense$ ack -rr -i 'old'
.Rproj.user/38B87E11/sdb/per/t/28624A5C
7: "folds" : "",
.Rproj.user/38B87E11/sdb/per/t/8A580C19
3: "contents" : "\n# This is the user-interface definition of a Shiny web application.\n# You can find out more about building applications with Shiny here:\n#\n# http://shiny.rstudio.com\n#\n\nlibrary(shiny)\n\nshinyUI(fluidPage(\n\n # Application title\n titlePanel(\"Old Faithful Geyser Data\"),\n\n # Sidebar with a slider input for number of bins\n sidebarLayout(\n sidebarPanel(\n sliderInput(\"bins\",\n \"Number of bins:\",\n min = 1,\n max = 50,\n value = 30)\n ),\n\n # Show a plot of the generated distribution\n mainPanel(\n plotOutput(\"distPlot\")\n )\n )\n))\n",
7: "folds" : "",
ui.R
13: titlePanel("Old Faithful Geyser Data"),
RStudio: 1.0.143
Asked by Konrad
(363 rep)
Jul 15, 2016, 11:41 AM
Last activity: Jun 26, 2017, 08:00 AM
Last activity: Jun 26, 2017, 08:00 AM