Reading Text Files

Let’s take a look at pr_check.yml in our .github/workflows folder:

cat .github/workflows/pr_check.yml
## on:
##   pull_request:
##     branches: main
##     paths-ignore:
##       - 'README.md'
##   workflow_dispatch:
## 
## jobs:
##   pr_check:
##     uses: r4ds/r4dsactions/.github/workflows/render_check.yml@main

The Pipe

  • Linux offers a pipe, |, similar to that of R and other functional languages
    • take the output of this | and give it to this as an input

To find the workflow branch:

cat .github/workflows/pr_check.yml | grep branches
##     branches: main

To show just the first six items in our current folder:

ls -a | head -n 6
## .
## ..
## .Rbuildignore
## .git
## .github
## .gitignore

Notice that bash returns the current folder and the parent folder as items.