bash
commandsbash
Commands<command> <flags + flag args> <command args>
command
: What to doflags + flag args
: Options for the command and options for those optionscommand args
: arguments to pass to the commandWe want to list files in the specified directory. The bash
command to list files is ls
.
command
: list.files()
flags + flag args
: all.files = TRUE
command args
: ".github"
command
: ls
flags + flag args
: -a
command args
: .github
this is a \
really really \
long command
Where am I? | Reference |
---|---|
Where was I born? | / |
What town do I live in? | |
Where do I live? | ~ |
Where am I now? | . |
Where was I just before where I am now? | .. |
*There’s no easy way to access your current mount point
Let’s say you are this file: /r4ds/do4ds/cohort1/chapter8.Rmd
File System Root | Drive | Home Folder | Folder (Your Room) | File |
---|---|---|---|---|
/ | r4ds | do4ds | cohort1 | chapter8.Rmd |
Revisiting the “Where am I? table”
Where am I? | Reference |
---|---|
Where was I born? | / |
What town do I live in? | r4ds |
Where do I live? | do4ds |
Where am I now? | cohort1 |
Where was I just before where I am now? | do4ds |
The bash
command to change directories is cd
. In this case, you start at /r4ds/do4ds/cohort1
which is the directory for your (chapter8.Rmd
) bedroom.
Quest | Directions |
---|---|
Visiting your cousin in cohort2 |
cd ../cohort2 |
Visiting your second cousin in the advr/cohort1 bookclub |
cd ../../advr/cohort1 |
You’ve gotten lost and don’t know where you are and need directions to your second cousin in the advr/cohort1 bookclub |
cd /r4ds/advr/cohort1 |
Stopping by the hospital where you were born because they have great grilled cheese sandwiches in the cafeteria | cd / |
Going back to your room | cd ~/cohort1 |
Any path with ..
is a relative path and only works from your current directory.
Let’s take a look at pr_check.yml
in our .github/workflows
folder:
|
, 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:
To show just the first six items in our current folder:
Notice that bash
returns the current folder and the parent folder as items.
Let’s say you are this file: /r4ds/do4ds/cohort1/chapter8.Rmd
File System Root | Drive | Home Folder | Folder (Your Room) | File |
---|---|---|---|---|
/ | r4ds | do4ds | cohort1 | chapter8.Rmd |
The rm
command will remove something, with the options to do so recursively (-r
) or to force it (-f
). You can also copy (cp
), move (mv
), or make or remove directories (mkdir
and rmdir
).
Construction Phase | Command |
---|---|
Move everything out of the kitchen into a spare room | mv ~/kitchen/* ~/spare_room |
Remove the kitchen appliances | rm ~/kitchen/stove.app ~/kitchen/fridge.app |
Demolish the kitchen | rmdir ~/kitchen |
Make a new kitchen | mkdir ~/kitchen |
Move everything into the new kitchen | mv ~/spare_room/* ~/kitchen |
You mv
or cp
from_here to_here
tar
packs and unpacks tarball files
tar -czf <archive name> <file(s)>
tar -xfv <archive name>
scp
stands for “secure copy” and is a combination of ssh
and cp
touch
creates a file>
is similar to pipe, but it will write to a file>>
is also similar to pipe, but it wall append to a filetouch file.txt
echo "this goes in the file" > file.txt
echo "this also goes in the file" >> file.txt
vi
, vim
, and nano
that work directly in the command line
To exit vim: 1. Hit the escape
key on your keyboard 2. Type one of these, making sure to include the :
- To write AND quit: :wq
- To quit without having made changes: :q
- To quit and not save changes: :q!
It’s okay if you don’t remember.