Skip to content

Commit d60aece

Browse files
committed
New topics, texts
1 parent 2146939 commit d60aece

File tree

11 files changed

+1668
-190
lines changed

11 files changed

+1668
-190
lines changed

presentation/linux_bash_metacentrum_course.tex

Lines changed: 214 additions & 186 deletions
Large diffs are not rendered by default.

scripts/awk_test_file.tab

Lines changed: 869 additions & 0 deletions
Large diffs are not rendered by default.

scripts/cut_awk_test_file.tsv

Lines changed: 509 additions & 0 deletions
Large diffs are not rendered by default.

scripts/diff_test_file_1.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
The Way that can be told of is not the eternal Way;
2+
The name that can be named is not the eternal name.
3+
The Nameless is the origin of Heaven and Earth;
4+
The Named is the mother of all things.
5+
Therefore let there always be non-being,
6+
so we may see their subtlety,
7+
And let there always be being,
8+
so we may see their outcome.
9+
The two are the same,
10+
But after they are produced,
11+
they have different names.
12+

scripts/diff_test_file_2.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
The Nameless is the origin of Heaven and Earth;
2+
The named is the mother of all things.
3+
4+
Therefore let there always be non-being,
5+
so we may see their subtlety,
6+
And let there always be being,
7+
so we may see their outcome.
8+
The two are the same,
9+
But after they are produced,
10+
they have different names.
11+
They both may be called deep and profound.
12+
Deeper and more profound,
13+
The door of all subtleties!
14+

scripts/interactive1.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
#!/bin/bash
2+
23
# Arguments are read from command line as parameters of the script
34
# Order has to be kept (well, not in this case, but generally yes)
5+
46
echo "Sum of two numbers $1 and $2 is `expr $1 + $2` ."
7+
58
# "$#" is available every time and contains number of parameters
69
# (variables) given to the script
10+
711
echo "Number of parameters is $# ."
12+
813
# "$*" is available every time and contains all supplied parameters
14+
915
echo "Those parameters were supplied: $*."
16+
1017
echo
18+
1119
exit

scripts/interactive2.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
#!/bin/bash
2+
23
# Arguments are read from user input (script asks for them)
4+
35
echo "Please, input first value to sum and press Enter"
6+
47
read V1
8+
59
echo "Please, input second value to sum and press Enter"
10+
611
read V2
12+
713
echo "Sum of two numbers $V1 and $V2 is `expr $V1 + $V2` ."
14+
815
echo
16+
917
exit

scripts/interactive3.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
2-
# Script has only one parameter ($1) provided as its parameter
2+
3+
# Script has only one parameter ($1) provided
34
# "case" is evaluating provided parameter and behaving accordingly
5+
46
case "$1" in
57
-d|--disk)
68
echo "Your disk usage is:"
@@ -18,4 +20,5 @@ case "$1" in
1820
-u or --uptime for computer uptime"
1921
;;
2022
esac
23+
2124
exit

scripts/interactive4.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
#!/bin/bash
2+
3+
# Regular expression explanation:
4+
# From the beginning of the line (^) there is number ([0-9])
5+
# at least one time (+) up to the end of the line ($)
26
NUMBER='^[0-9]+$'
7+
38
if [ "$#" -ne "3" ]; then
49
echo "Error! Requiring 3 parameters! Received $#.
5-
Usage number1 -plus/-minus/-product/-quotient number2
10+
Usage: number1 -plus/-minus/-product/-quotient number2
611
Use -plus for sum, -minus for difference, -product
712
for multiplication or -quotient for quotient."
813
exit 1
914
fi
15+
16+
# "=~" means we are testing if $1 fits to regular expression in $NUMBER
17+
1018
if [[ ! $1 =~ $NUMBER ]]; then
1119
echo "Parameter 1 is not an integer!"
1220
exit 1
1321
fi
22+
1423
if [[ ! $3 =~ $NUMBER ]]; then
1524
echo "Parameter 3 is not an integer!"
1625
exit 1
1726
fi
27+
1828
case $2 in
1929
-plus) expr $1 '+' $3;;
2030
-minus) expr $1 '-' $3;;
@@ -26,4 +36,5 @@ case $2 in
2636
-product for multiplication or -quotient
2737
for quotient.";;
2838
esac
39+
2940
exit

scripts/metacentrum.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
#!/bin/bash
2+
23
# Modify the script according to your needs!
4+
35
# Set data directories
46
WORKDIR="bayes_batch"
57
DATADIR="/storage/praha1/home/$LOGNAME"
8+
69
# So there is directory /storage/praha1/home/gunnera/bayes_batch containing all the data needed for calculations
10+
711
# Clean-up of SCRATCH (it is temporal directory created by server) - the commands will be launched on the end when the job is done
812
trap 'clean_scratch' TERM EXIT
913
trap 'cp -ar $SCRATCHDIR $DATADIR/ && clean_scratch' TERM
10-
# Prepare the task - copy all needed files from working directory
11-
# into particular computer which will finally do the calculations
14+
15+
# Prepare the task - copy all needed files from working directory into particular computer which will finally do the calculations
1216
cp -ar $DATADIR/$WORKDIR/* $SCRATCHDIR/ || exit 1
17+
1318
# Change working directory - script goes to the directory where calculations are done
1419
cd $SCRATCHDIR/ || exit 2 # If it fails, exit script
20+
1521
# Prepare calculations - load required application modules
1622
# See https://wiki.metacentrum.cz/wiki/Kategorie:Applications
1723
# Every application module is loaded by "modile add XXX"
1824
. /packages/run/modules-2.0/init/sh
1925
module add parallel # In this case GNU Parallel and MrBayes
2026
module add mrbayes-3.2.2
27+
2128
# Launch the analysis - calculate MrBayes for multiple files
2229
ls -1 *.nexus | parallel -j 8 'mb {} | tee -a {}.log'
30+
2331
# Copy results back to home directory
2432
cp -ar $SCRATCHDIR $DATADIR/$WORKDIR || export CLEAN_SCRATCH=false
33+
2534
# This is all needed, the script is ready to be launched...
35+
2636
# Don't forget to make it executable and modify it according to your needs... If the script was written on Windows, convert EOL and possibly encoding as well...
37+
38+
exit

0 commit comments

Comments
 (0)