generated from allisonhorst/meds-distill-template
-
Notifications
You must be signed in to change notification settings - Fork 10
/
day2-cli_practice.qmd
75 lines (52 loc) · 2.52 KB
/
day2-cli_practice.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
title: "Practicing CLI"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Files and directories
In the following code examples, you need to type the command, but not include
the command prompt (e.g., `brun@workbench-1:~$`) which just shows that the computer
is ready to accept a command.
We'll start by:
- creating two directories with `mkdir` (make directory)
- create a simple text file using `echo`
- Show the contents of that file using `cat` (concatenate)
```bash
brun@workbench-1:~$ mkdir cli_intro
brun@workbench-1:~$ mkdir cli_intro/data
brun@workbench-1:~$ echo "# Tutorial files related to CLI" > cli_intro/README.md
brun@workbench-1:~$ cat cli_intro/README.md
# Tutorial files related to CLI
brun@workbench-1:~$
```
### Your turn
#### Next, let's copy another file and look around in the directories:
- copy a file into your directory with `cp` (copy)
- change our working directory to that newly created directory using `cd` (change directory)
- list the files in the directory with `ls` (list)
- look where we are in the filesystem using `pwd` (print working directory)
- get an overview of the directory contents using `tree`
Upload files from your local machine to the server using the different techniques mentioned above, You can download the `10min-loop.R` file to your local machine from https://aurora.nceas.ucsb.edu/~brun/10min-loop.R
#### Try with a folder:
- download the data to your laptop: https://aurora.nceas.ucsb.edu/~brun/sampledata.zip
- unzip the folder
- upload the folder to workbench-1 using scp or cyberduck
Your should end up with something like this:
```bash
brun@workbench-1:~$ ls -l
total 16
-rw-r--r-- 1 brun esmdomainusers 90 Aug 25 05:36 10min-loop.R
drwxr-xr-x 3 brun esmdomainusers 4096 Aug 24 23:05 github
drwxr-xr-x 3 brun esmdomainusers 4096 Aug 16 05:00 R
drwxr-xr-x 2 brun esmdomainusers 4096 Aug 25 05:37 sampledata
```
### Your turn
Now, let's create two subdirectories in the data directory: `mammals` and `plots`
- move using `cp` all the mammals files from the `sampledata` folder to the `mammals` subdirectory; hint: you can use the wildcard `*`
- move using `mv` the other files files from the `sampledata` folder to the `plots` subdirectory
- double check it is done using `cd` and `ls`
- remove `rm` the `sampledata` directory; hint: `rmdir` can only remove empty directories
- bonus: add a text file `data_listing.txt` in the `data` folder that lists all the files in it
## Aknowledgements
Adapted from Matt Jones, OSS 2017, https://github.com/NCEAS/oss-lessons