# got to you home directory
cd ~
# create the new directory
mkdir cli_intro
# go inside it
cd cli_intro
# Download the qmd from GitHub
curl --output cli-handson-files.qmd https://raw.githubusercontent.com/brunj7/eds214-handson-cli/main/cli-handson-files.qmd
# Do a check that it works
ls -F. # What does `-F` do!?Practicing bash
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.
Setup
Let’s start by downloading the quarto document from GitHub so you can save your commands in it:
- create a
cli_introdirectory in your home directory on workbench-1 - download the qmd file
Let’s keep going!!
- create a
README.mdfile inside thecli_introdirectory & add the following title:# Tutorial files related to CLIto it (check outecho)- Hint: you can do this in one line!
- Show the contents of that file using
cat(concatenate)
# brun@workbench-1:~$ cd ~/cli_introA little more file manipulations
Get a file from a remote server
- download the file
10min-loop.Rto your home directory on workbench-1 - create directory
codeinside yourcli_introfolder - move
mvthis file to yourcli_intro/codedirectory - 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
# brun@workbench-1:~$ cd ~
# brun@workbench-1:~$ curl --output 10min-loop.R https://aurora.nceas.ucsb.edu/~brun/10min-loop.RTry with a folder:
- download the data to workbench-1 from https://aurora.nceas.ucsb.edu/~brun/sampledata.zip
- unzip the folder
# brun@workbench-1:~$ cd ~/cli_intro
# brun@workbench-1:~/cli_intro$ curl --output sampledata.zip https://aurora.nceas.ucsb.edu/~brun/sampledata.zip
# brun@workbench-1:~/cli_intro$ ls
# brun@workbench-1:~/cli_intro$ unzip sampledata.zip
# brun@workbench-1:~/cli_intro$ tree .Your should end up with something like this:
# brun@workbench-1:~/cli_intro$ tree
.
├── code
│ └── 10min-loop.R
├── README.md
└── sampledata
├── paleo-mammals.txt
├── paleo-mammals-v2.txt
├── paleo-mammals-v3.txt
├── stem.csv
└── tree.csv
2 directories, 7 filesYour turn
Now, let’s organize those data!!
- create a new directory
datain thecli_introdirectory - move the
sampledatadirectory inside thedatadirectory - create two directories
mammalsandplotsinside thedatadirectory - move using
cpto copy all the mammals files from thesampledatafolder to themammalssubdirectory; hint: you can use the wildcard* - move using
mvthe other files files from thesampledatafolder to theplotssubdirectory - double check it is done using
cdandls - remove
rmthesampledatadirectory; hint:rmdircan only remove empty directories
Your should end up with something like this:
# brun@workbench-1:~/cli_intro$ tree
.
├── code
│ └── 10min-loop.R
├── data
│ ├── mammals
│ │ ├── paleo-mammals.txt
│ │ ├── paleo-mammals-v2.txt
│ │ └── paleo-mammals-v3.txt
│ └── plots
│ ├── stem.csv
│ └── tree.csv
└── README.md
4 directories, 7 filesBonuses
- add a text file
data_listing.txtin thedatafolder that lists all the files in it - add a text file
nb_lines_listing.txtin thedatafolder that counts the number of lines in each files and orders the files with highest being first - can you make the
cli-introa git repository?
BTW, do you wonder what are the differences between the various mammals files?
diff paleo-mammals.txt paleo-mammals-v2.txtAknowledgements
Adapted from Matt Jones, OSS 2017, https://github.com/NCEAS/oss-lessons
Back to main Repo