owned this note
owned this note
Published
Linked with GitHub
All content is publicly available under the Creative Commons Attribution License: https://creativecommons.org/licenses/by/4.0/
---
# Software Carpentry Workshop
- HIFIS - Helmholtz Federated IT Services
- April 22nd and April 23rd, 2020
## Important Links
### Zoom
Join Zoom Meeting
https://zoom.us/j/552801192?pwd=jqUVTd-TCY9LwBqvWvLi-4SnJA02Bw
Meeting ID: 552 801 192
Password: 210933
One tap mobile
+493056795800,,552801192#,,#,210933# Germany
+496950502596,,552801192#,,#,210933# Germany
Dial by your location
+49 30 5679 5800 Germany
+49 695 050 2596 Germany
+49 69 7104 9922 Germany
+41 43 210 70 42 Switzerland
+41 43 210 71 08 Switzerland
+41 22 591 00 05 Switzerland
+41 22 591 01 56 Switzerland
+41 31 528 09 88 Switzerland
+43 12 535 501 Austria
+43 12 535 502 Austria
+43 670 309 0165 Austria
+43 72 011 5988 Austria
Meeting ID: 552 801 192
Password: 210933
Find your local number: https://zoom.us/u/aiI7xleSD
### Event Page
https://hifis.gitlab.io/2020-02-22-hzdr
## Day 1
## Please Say Hi!
Just add your name in the list **below**!
- Peter Steinbach
- Jonas Höhndorf
- Lucas Pereira
- Anna Sommer
- Maximilian Demnitz
- Ivan Fotev
- Kathi Woitas
- Sabrina Palazzese
- Canberk Karaerkek
- Isabelle Jessat
- Jakub Rehor
- Gowrishankar Hallilingaiah
- Thiyagarajan Raman
- Pavel Evtushenko (PE)
- Trang-Anh Nguyen-Le
- Benedikt Nimmervoll
- Sadegh Ghaderzadeh
- Muthu Vallinayagam (MV)
## Warm-up Question
Please write down your main field of expertise and your most favorite cake (can also be a sweet):
- PS: Machine Learning and Data Science, double chocolate cream cake
- SP: Quantum Magnetism and Superconductivity, chocolate cake :) always chocolate.
- IJ: Radiochemistry / surface chemistry, everything with a looooot of chocolate
- JR: Vehicle dynamics in MBS-Simulations, Eierschecke
- AS: Process Engineering, brownies
- MD: Luminescence spectroscopy/chemistry, apple pie
- LP: Mineral characterization and processing + data science, carrot cake with brigadeiro topping
- GH: Electromagnetics and rf engineering, Gulab jamoon ((sweet))
- TA: Biomedical Engineering, blueberry cheesecake
- IF: Spectroscopy in solid state physics, Zupfkuchen
- JH: liquid metal batteries (master thesis), no cake :D
- KW: Library science, Rhubarb pie with crumble
- RT: Magetism and Transport properties, Choco cream
- CK: Engineering Physics, Lava cake
- PE: Accelerator and FEL physics, beam diagnostics; best cake - the one that is not there...
- NA: Theoretical Physics, QED,
- BN: Molecular Cell Biology, Embryology; Rhabarberkuchen
- MV: DFT simulation on Fe based Nuclear materials
## Introduction to the Shell, aka how to automate things
Please turn to the setup: http://swcarpentry.github.io/shell-novice/setup.html
Ready to go? (download zip file, unpack zipfile into Desktop on your laptop, open a terminal)
PS
LP
AS
IF
GH
SP
JR
KWl
TA
IJ
MD
JH
PE
BN
NA
CK
MV
# Commands list:
* `ls` - list of files (**l**i**s**t)
* `pwd` - current folder (**p**rint **w**orking **d**irectory)
* `clear`- clear the terminal screen
* `man` - get the **man**ual for a command
* Online Version e.g. https://www.kernel.org/doc/man-pages/
* `cd` - moving inside the file system (**c**hange **d**irectory)
* `mkdir` - **m**a**k**e a new **dir**ectory
* `nano` - Launch the [_nano_](https://en.wikipedia.org/wiki/GNU_nano) editor
* `mv` - **m**o**v**e a file or directory
* Can also be used for renaming
* `cp` - **c**o**p**y a file
* For copying a directory use the `-r` flag
* `touch`- creates an empty file
* `rm` - **r**e**m**ove a file
* Use the flag `-i` to be asked for confirmation
* Use `-r` for directories (recursively, i.e. with everything in it)
* `wc` - get the **w**ord **c**ount in a file
* `cat` - put the content of a file on the terminal output (con**cat**enate)
* Cats are curious and look into everything you give them
* `less` - similar to `cat` but pager-based (like `man`)
* Better for longer files
* `sort` - sort input lexicographically
* [Explanation for different `sort` default behaviours](https://unix.stackexchange.com/questions/43465/whats-the-default-order-of-linux-sort)
* `head` - show the first lines of a file
* `tail` - show the last lines of a file
* `echo` - print argument on the terminal output
* Very useful in scripts or to examine the contents of variables
## Where are you?
Please copy and paste the output of the `pwd` command below:
- PS /home/learner
- LP /c/Users/Lucas/Desktop
- JH /c/Users/Jonas Höhndorf
- TA /c/Users/tranganh
- NA /Users/naser
- JR /c/Users/rehor/Desktop
- SP /c/Users/palazz55
- PE /Users/pavel/desktop/data-shell
- AS /home/anna
- GH /home/gowrishankar/data-shell
- MD /c/Users/User
- CK /c/Users/Spec
- KW /c/Users/kwoit/Desktop
- BN /mnt/c/Users/klein/Desktop/data-shell: I am using the GIT shell on WINDOWS :(
- IJ /c/Users/Maximilian
- IF /c/Users/Jelena
- MV /home/vallin59/scratch
## Exercise: Listing in Reverse Chronological Order
By default ls lists the contents of a directory in alphabetical order by name. The command ls `-t` lists items by time of last change instead of alphabetically. The command `ls -r` lists the contents of a directory in reverse order. Which file is displayed last when you combine the `-t` and `-r` flags? Hint: You may need to use the `-l` flag to see the last changed dates. Use `Desktop/data-shell/data` as an example or any other folder that you find suitable.
- LP: 5, 7, 8, 9
- JR: 5, 7, 9
- IF: cd ..
- SP: 5, 9
- NA 5, 9 (No)
- GH : 9,8
- JH: 8, 9, 5, 7
- MD: 5, 9, 8
- IJ 5, 8, 9
- AS: 5, 8, 9
- KW: 2 (works with me - but not cd /home), 5, 9, 3, 8
- RT: cd and cd ..
- CK: 3,5,6,7,9
- BN 9 (possibly 5,8; won't work on my Windows PC despite I set the HOME variable)
- MV cd ~ ; cd /Users/ananda ; cd .. ; 3, 5, 8, 9
- TA: 5,9
- PE: on a Mac “cd”, “cd ~"
## Exercise on Relative Paths
1. ../backup: No such file or directory
2. 2012-12-01 2013-01-08 2013-01-27
3. 2012-12-01/ 2013-01-08/ 2013-01-27/
4. original/ pnas_final/ pnas_sub/
Put your initials behind the answer that you think is correct
NA1. PE GH RT NA
2.
3.
4.
5.JR BN AS KW IJ MD TA LP SP CK IF JH #
MV : 4 ; option 3 is correct if we use single perion in ls " ls -F ./backup"
---
## Exercise: Moving and Copying
1. proteins-saved.dat recombine
2. recombine
3. proteins.dat recombine
4. proteins-saved.dat
Put your initials behind the answer that you think is correct:
1. LP, AS, JR, MD, JH, IJ, IJ, TA, RT
2. PE, IF, BN, MV, GH
3. CK
4. KW NA
## Exercise on Wildcards
**List filenames matching a pattern**
When run in the `molecules` directory, which `ls` command(s) will produce this output?
`ethane.pdb methane.pdb`
```
1. ls *t*ane.pdb
ethane.pdb methane.pdb octane.pdb pentane.pdb
2. ls *t?ne.*
octane.pdb pentane.pdb
3. ls *t??ne.pdb
ethane.pdb methane.pdb
4. ls ethane.*
ethane.pdb
```
1. , RT
2.
3. MD, NA, SP, LP, IJ (and ls *ethane.pdb), GH, AS, CK, JH, BN , IF, PE, TA, mv
4.
## Day 1 morning feedback
Below, list something that you liked or learned this morning:
- IF: we learned and practised a lot of stuff in short time, without getting confused. The pace is optimal.
- KW: navigating through dir with Bash, manipulating files - was very fine!
- LP: This last part with the pipe. It is really interesting to see how to optimize actions with the bash
- JH: relaxed pace, nice start with the topic for beginners
- AS: wide varity of commands to work with the bash
- JR: speakers speed, learned basic file and directory manipulation, lost fear using the bash
- CK: same time practicing and exercise check from here very useful at all
- IJ: pipes and useful cmds --> exercises
- NA we learned quite a lot, especially directing, managing files, etc
- SP: moving through folders and creating new files within the bash and working with different versions of files
- GH : I used some of the commands but i didn't work much with arguments. Obviously piping was good to know.
- TA: managing directory, create text files and pipe. The excercises were helpful to understand the logic. Good pace, simutaneously instruction and hand-on practice
- MD: learning how to use all the different prompts and how to navigate in the terminal
- BN: finally understood piping and redirecting the output
- MV: it is very good recap in my case
- RT: feel better even we know some of commands already known by practising in order
- PE: some new shell commands, good speed
Below, list something that you didn't like, that you want us to improve or that you didn't understand:
- JR: the sort of polling in HackMD
-NA: I am not sure I got the whole last 10 mins, that would be great if you make a short review after lunch
SP: this is very useful: https://swcarpentry.github.io/shell-novice/reference/
-
# Lunch break until 13:00
## Exercise: For loop with `ls -F`
$ for filename in *.dat
> do
> ls -F $filename
> done
basilisk.dat
minotaur.dat
unicorn.dat
KW: $ for filename in *.dat; do ls -F $filename; done basilisk.dat
minotaur.dat
unicorn.dat
- PE
for loop1 in *.dat; do ls -F unicorn.dat; done
NA: for filename in *.dat; do ls -F $filename; done
basilisk.dat
minotaur.dat
unicorn.dat
This is what I executed after the
`$ for datafile in NENE*[AB].txt; do bash goostats $datafile stats-$datafile;done`