Go to the workshop website and follow the instructions for your operating system to setup each of:
UCLARC
(“8fumvhgsy” on Thursday morning) to follow along and submit answers to the exercises.shell-lesson-data.zip
file and Unzip/extract it, save to your Desktop.python-novice-inflammation-data.zip
file and Unzip/extract it, save to your Desktop.Instructors: Ben (Bash) & David Pérez-Suárez(Git)
Helpers: Tara, Nathan, David Wong, Elizabeth (AM), Marin (PM)
Instructors:
Helpers: Tara, Nathan, Elizabeth (AM), Marin (PM)
Contribute to this document by adding notes about the class below.
ls
lists the files
ls -F
shows the folders by adding a /
at the end of the folders, those ending with *
are executable files.ls -a
shows all files including those starting with a .
(Hidden files).man ls
or in Windows ls --help
shows the help for the ls
command.pwd
prints the working directoryls D
+ tab will show that can be either “Documents”, “Downloads” and/or anything that starts with D
.clear
cleans up the screen (but doesn’t clean the history).cd
change directory.
cd ..
changes the directory into the one above (also works with ls
- it will show you the content of the directory above)cd
without any argument it will move you to your home directory (i.e., /home/username
, /Users/username
or something similar).cd ~
also takes you to your home, but you can also use it to got to something relative to that: cd ~/Desktop
will move you to the Desktop no matter where you are.mkdir
make a new directory.nano
is a text editor that work directly on the command line
nano filename.txt
will open (or create if doesn’t exist) a file called filename.txt
^
means the key ctrl, so ^X
for exit means pressing ctrl+x.touch filename
will create a file.rm filename
is for removing files.mv <source 1> <source 2> ... <source n> <destination>
moves files from one place to another, destination is expected to be a directory.
mv <Old_file_name> <new_file_name>
can be used to change file names.wc <filename(s)>
gives a word count inside the file with format:
<#.lines> <#.words> <#.characters> <filename>
sort
putting digits into numerical order (with -n
option) or words into alphabetical orderhead
display the first line of a file
head -n <number_of_lines>
tail
similar to head
but displaying from the last line.cat <filename>
prints file contents in the terminal.[some_command] > output.txt
writes the output of some_command to a file called output.txt
, doesn’t need to be in txt
format.
>
overwrites what’s inside the file if it already exists.>>
appends to existing file.[command_1]
|[command_2]
the output of command_1 will be fed into command_2.
[command_1]|[command_2]|...|[command_n]
, the commands will run from 1 to n in order.cut
cut each line of a file.echo
print string.Create a plot showing the standard deviation (numpy.std) of the inflammation data for each day across all patients.
Add your new plot to your previous group of plots
Change the plot figure so the plots are vertical and not horizontal
# slice only the last 4 characters of the string
string_for_slicing = 'Observation date: 02-Feb-2013'
# slice only the last 4 items in the list
list_for_slicing = [['fluorine', 'F'],
['chlorine', 'Cl'],
['bromine', 'Br'],
['iodine', 'I'],
['astatine', 'At']]
beatles = "In an octopus's garden in the shade"
# use string slicing to print `I notpssgre ntesae` from the `beatles` variable
# write a loop that sums up every element in this list
numbers = [124, 402, 36]
# should be 562
x = 5
coefs = [2, 4, 3]
y = coefs[0] * x**0 + coefs[1] * x**1 + coefs[2] * x**2
print(y)
# write a loop using enumerate do calculate the polynomial