Advanced Linux Usage 2017-10-24 Martin Dahl - - PowerPoint PPT Presentation

advanced linux usage
SMART_READER_LITE
LIVE PREVIEW

Advanced Linux Usage 2017-10-24 Martin Dahl - - PowerPoint PPT Presentation

Advanced Linux Usage 2017-10-24 Martin Dahl martin.dahlo@scilifelab.uu.se Valentin Georgiev valentin.georgiev@icm.uu.se Shell and Bash the Shell is a Command Line Interface (CLI) Bash is one particular shell tcsh, zsh are also shell


slide-1
SLIDE 1
slide-2
SLIDE 2

Advanced Linux Usage

2017-10-24 Martin Dahlö martin.dahlo@scilifelab.uu.se Valentin Georgiev valentin.georgiev@icm.uu.se

slide-3
SLIDE 3

Shell and Bash

the Shell is a Command Line Interface (CLI) Bash is one particular shell tcsh, zsh are also shell programs

slide-4
SLIDE 4

Multiple files

  • Same program, many files
slide-5
SLIDE 5

Multiple files

  • Same program, many files
slide-6
SLIDE 6

Multiple files

  • Same program, many files
slide-7
SLIDE 7

Multiple files

  • Same program, many files
slide-8
SLIDE 8

Multiple files

  • Same program, many files

○ 10 files? Ok ○ 1000 files? Not ok..

slide-9
SLIDE 9

Multiple files

  • Same program, many files

○ 10 files? Ok ○ 1000 files? Not ok..

  • Reproducibility

○ Self and others

slide-10
SLIDE 10

Multiple files

  • Same program, many files

○ 10 files? Ok ○ 1000 files? Not ok..

  • Reproducibility

○ Self and others

The answer - write a script!

slide-11
SLIDE 11

Basic script

slide-12
SLIDE 12

Basic script

slide-13
SLIDE 13

Basic script

slide-14
SLIDE 14

Basic script

slide-15
SLIDE 15

Basic script

slide-16
SLIDE 16

Basic script

slide-17
SLIDE 17

Basic script

slide-18
SLIDE 18

Variables

  • Assigning

my_variable=5 my_variable=”nice text”

slide-19
SLIDE 19

Variables

  • Assigning

my_variable=5 my_variable=”nice text”

  • Using

$my_variable

slide-20
SLIDE 20

Variables

  • Assigning

my_variable=5 my_variable=”nice text”

  • Using

$my_variable $ my_variable=”Pia”

slide-21
SLIDE 21
  • Assigning

my_variable=5 my_variable=”nice text”

  • Using

$my_variable $ my_variable=”Pia” $ echo “Hello, $my_variable! ”

Variables

slide-22
SLIDE 22
  • Assigning

my_variable=5 my_variable=”nice text”

  • Using

$my_variable $ my_variable=”Pia” $ echo “Hello, $my_variable! ” Hello, Pia!

Variables

slide-23
SLIDE 23

Variables

slide-24
SLIDE 24

Variables

slide-25
SLIDE 25

Variables

slide-26
SLIDE 26

Variables

slide-27
SLIDE 27

Loops

for variable in 1 2 3; do echo $variable done

slide-28
SLIDE 28

Loops

for variable in text works too; do echo $variable done

slide-29
SLIDE 29

Loops

for variable in mix them 5; do echo $variable done

slide-30
SLIDE 30

Loops

slide-31
SLIDE 31

Loops

slide-32
SLIDE 32

Loops

slide-33
SLIDE 33

Loop over files

slide-34
SLIDE 34

Loop over files

slide-35
SLIDE 35

Loop over files

slide-36
SLIDE 36

Loop over files

slide-37
SLIDE 37

Loop over files

slide-38
SLIDE 38

Loop over files

slide-39
SLIDE 39

Loop over files

slide-40
SLIDE 40

Loop over files

slide-41
SLIDE 41

Loop over files

slide-42
SLIDE 42

Loop over files

slide-43
SLIDE 43

If

  • Control statement

if true; then

echo ”This is true”

fi

slide-44
SLIDE 44

If

  • Control statement

if false; then

echo ”This is true”

fi

slide-45
SLIDE 45

If

  • Control statement

if [[ 5 < 9 ]]; then

echo ”This is true”

fi

slide-46
SLIDE 46

If

  • Control statement

if [[ 5 > 9 ]]; then

echo ”This is true”

fi

slide-47
SLIDE 47

If

  • Control statement

if [[ 5 == 9 ]]; then

echo ”This is true”

fi

slide-48
SLIDE 48

If

  • Control statement

if [[ ”Hello” == ”Hello” ]]; then

echo ”This is true”

fi

slide-49
SLIDE 49

If

  • Control statement

if [[ ”Hello” == ”Hi” ]]; then

echo ”This is true”

fi

slide-50
SLIDE 50

If

  • Control statement

if [[ ”Hello” == ”Hel”* ]]; then

echo ”This is true”

fi

slide-51
SLIDE 51

If

  • For all samples except dog
slide-52
SLIDE 52

If

  • For all samples except dog
slide-53
SLIDE 53

If

  • For all samples except dog

Ex: $file is /path/to/dog_1.bam

slide-54
SLIDE 54

If

  • For all samples except dog

Ex: $file is /path/to/dog_1.bam basename $file

slide-55
SLIDE 55

If

  • For all samples except dog

Ex: $file is /path/to/dog_1.bam basename $file dog_1.bam

slide-56
SLIDE 56

If

  • For all samples except dog

Ex: $file is /path/to/dog_1.bam basename $file dog_1.bam

slide-57
SLIDE 57

If

  • For all samples except dog

Ex: $file is /path/to/dog_1.bam basename $file dog_1.bam

slide-58
SLIDE 58

Different languages

  • Programming is programming

○ Perl, Python, Bash, and more

slide-59
SLIDE 59

Different languages

  • Programming is programming

○ Perl, Python, Bash, and more

slide-60
SLIDE 60

Different languages

  • Programming is programming

○ Perl, Python, Bash, and more

slide-61
SLIDE 61

Different languages

  • Programming is programming

○ Perl, Python, Bash, and more

slide-62
SLIDE 62

Different languages

  • Programming is programming

○ Perl, Python, Bash, and more

  • Start with one, git gud, (learn another)
slide-63
SLIDE 63

Different languages

  • Programming is programming

○ Perl, Python, Bash, and more

  • Start with one, git gud, (learn another)

PYTHON

slide-64
SLIDE 64

Laboratory time! (yet again)