diff --git a/_episodes/03-file-transfer.md b/_episodes/03-file-transfer.md index 7f65865..dfb18bd 100644 --- a/_episodes/03-file-transfer.md +++ b/_episodes/03-file-transfer.md @@ -1,14 +1,15 @@ - --- title: "Transferring Files" teaching: 10 exercises: 0 questions: -- "How to use wget, curl and lftp to transfer file?" +- "How to use wget, curl, and lftp to transfer files?" objectives: -- "FIXME" +- "To know different ways to interact with remote files" keypoints: -- "FIXME" +- "`wget` is the default tool, available in most Linux, to download file." +- "`curl` is another tools to download file which support larger protocols." +- "`lftp` is sosphisticated file transfer program with more capability including torrent support." --- There are other ways to interact with remote files other than git. @@ -94,7 +95,7 @@ where: `-m` is for mirroring with time stamping, infinite recursion depth, and preservation of FTP directory settings `-k` converts links to make them suitable for local viewing -`-q` supresses the output to the screen +`-q` suppresses the output to the screen The above command can also save the clone the contents of one domain to another if we are using ssh or sshfs to access a webserver. diff --git a/_episodes/04-permissions.md b/_episodes/04-permissions.md index 6e50e80..c685c35 100644 --- a/_episodes/04-permissions.md +++ b/_episodes/04-permissions.md @@ -86,9 +86,9 @@ For example, if a file had the following set of permissions: it would mean that: -* the file's owner can read and write it, but not run it; -* other people in the file's group can read it, but not modify it or run it; and -* everybody else can do nothing with it at all. +* the file's owner can read and write it, but not run it; +* other people in the file's group can read it, but not modify it or run it; and +* everybody else can do nothing with it at all. Let's look at this model in action. If we `cd` into the `labs` directory and run `ls -F`, @@ -98,13 +98,16 @@ i.e., that it's (probably) something the computer can run. ~~~ -$ cd labs -$ ls -F +cd labs +ls -F ~~~ + {: .bash} + ~~~ safety.txt setup* waiver.txt ~~~ + {: .output} > ## Necessary But Not Sufficient @@ -124,14 +127,17 @@ safety.txt setup* waiver.txt Now let's run the command `ls -l`: ~~~ -$ ls -l +ls -l ~~~ + {: .bash} + ~~~ -rw-rw-r-- 1 vlad bio 1158 2010-07-11 08:22 safety.txt -rwxr-xr-x 1 vlad bio 31988 2010-07-23 20:04 setup -rw-rw-r-- 1 vlad bio 2312 2010-07-11 08:23 waiver.txt ~~~ + {: .output} The `-l` flag tells `ls` to give us a long-form listing. @@ -173,13 +179,15 @@ Here's a long-form listing showing the permissions on the final grades in the course Vlad is teaching: ~~~ -$ ls -l final.grd +ls -l final.grd ~~~ + {: .bash} ~~~ -rwxrwxrwx 1 vlad bio 4215 2010-08-29 22:30 final.grd ~~~ + {: .output} Whoops: everyone in the world can read it—and what's worse, @@ -190,8 +198,9 @@ which would almost certainly not work.) The command to change the owner's permissions to `rw-` is: ~~~ -$ chmod u=rw final.grd +chmod u=rw final.grd ~~~ + {: .bash} The 'u' signals that we're changing the privileges @@ -201,60 +210,68 @@ A quick `ls -l` shows us that it worked, because the owner's permissions are now set to read and write: ~~~ -$ ls -l final.grd +ls -l final.grd ~~~ + {: .bash} ~~~ -rw-rwxrwx 1 vlad bio 4215 2010-08-30 08:19 final.grd ~~~ + {: .output} Let's run `chmod` again to give the group read-only permission: ~~~ -$ chmod g=r final.grd -$ ls -l final.grd +chmod g=r final.grd +ls -l final.grd ~~~ + {: .bash} ~~~ -rw-r--rw- 1 vlad bio 4215 2010-08-30 08:19 final.grd ~~~ + {: .output} And finally, -let's give "all" (everyone on the system who isn't the file's owner or in its group) no permissions at all: +let's give "others" (everyone on the system who isn't the file's owner or in its group) no permissions at all: ~~~ -$ chmod a= final.grd -$ ls -l final.grd +chmod o= final.grd +ls -l final.grd ~~~ + {: .bash} ~~~ -rw-r----- 1 vlad bio 4215 2010-08-30 08:20 final.grd ~~~ + {: .output} Here, -the 'a' signals that we're changing permissions for "all", +the 'o' signals that we're changing permissions for "others", and since there's nothing on the right of the "=", -"all"'s new permissions are empty. +"others"'s new permissions are empty. We can search by permissions, too. Here, for example, we can use `-type f -perm -u=x` to find files that the user can execute: ~~~ -$ find . -type f -perm -u=x +find . -type f -perm -u=x ~~~ + {: .bash} ~~~ ./tools/format ./tools/stats ~~~ + {: .output} Before we go any further, @@ -262,8 +279,9 @@ let's run `ls -a -l` to get a long-form listing that includes directory entries that are normally hidden: ~~~ -$ ls -a -l +ls -a -l ~~~ + {: .bash} ~~~ @@ -273,6 +291,7 @@ drwxr-xr-x 1 vlad bio 8192 2010-08-27 23:11 .. -rwxr-xr-x 1 vlad bio 31988 2010-07-23 20:04 setup -rw-rw-r-- 1 vlad bio 2312 2010-07-11 08:23 waiver.txt ~~~ + {: .output} The permissions for `.` and `..` (this directory and its parent) start with a 'd'. @@ -303,6 +322,40 @@ She's allowed to go through `pluto`, but not to look at what's there. This trick gives people a way to make some of their directories visible to the world as a whole without opening up everything else. +## Shebang + +Shebang is the #! syntax used in scripts to indicate an interpreter for execution under UNIX/Linux operating systems. For shell, we can use two different approaches, + +~~~{.bash} +#!/bin/bash +~~~ + +or, + +~~~{.bash} +#!/usr/bin/env bash +~~~ + +at the top of the script. The second approach is more portable and recommended. +For instance, check the `file_info.sh` script in the `code` directory. +First, after creating or downloading the script, we need to make it executable using `chmod` command. + +~~~{.bash} +chmod u+x file_info.sh +~~~ + +The `u+x` option is used to permit the "**u**ser to e**x**ecute" the script. +Then we can run the script using the following command: + +~~~{.bash} +./file_info.sh example.txt +~~~ + +Shebang is necessary if we want to run the code without explicitly telling Unix what the interpreter is. +We still run the code without shebang, i.e., by telling the interpreter to run the code, +e.g., `bash file_info.sh example.txt`. If we run the code directly but no shebang +is given, or the permission is not given, the code will not run ("Permission denied" error). + ## What about Windows? Those are the basics of permissions on Unix. @@ -322,15 +375,17 @@ Some modern variants of Unix support ACLs as well as the older read-write-execut but hardly anyone uses them. > ## Challenge +> > If `ls -l myfile.php` returns the following details: > > ~~~ > -rwxr-xr-- 1 caro zoo 2312 2014-10-25 18:30 myfile.php > ~~~ +> > {: .output} -> +> > Which of the following statements is true? -> +> > 1. caro (the owner) can read, write, and execute myfile.php > 2. caro (the owner) cannot write to myfile.php > 3. members of caro (a group) can read, write, and execute myfile.php diff --git a/_episodes/05-directory-structure.md b/_episodes/05-directory-structure.md deleted file mode 100644 index cee67e4..0000000 --- a/_episodes/05-directory-structure.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: Directory structure -teaching: 5 -exercises: 0 -questions: -- "Understanding the concept of Unix directory structure" -objectives: -- "FIXME" -keypoints: -- "FIXME" ---- - -All Unix files are integrated in a single directory structure. The file-system is arranged in a structure like an inverted tree. The top of this tree is the root and is written as a slash ‘/’. - -## The `tree` command - -FIXME diff --git a/_episodes/06-job-control.md b/_episodes/05-job-control.md similarity index 99% rename from _episodes/06-job-control.md rename to _episodes/05-job-control.md index da3beba..7330f39 100644 --- a/_episodes/06-job-control.md +++ b/_episodes/05-job-control.md @@ -1,5 +1,5 @@ --- -title: Job control +title: Job Control teaching: 5 exercises: 0 questions: diff --git a/_episodes/07-aliases.md b/_episodes/06-aliases.md similarity index 98% rename from _episodes/07-aliases.md rename to _episodes/06-aliases.md index 8915182..27451ef 100644 --- a/_episodes/07-aliases.md +++ b/_episodes/06-aliases.md @@ -1,5 +1,5 @@ --- -title: Aliases and bash customization +title: Aliases and Bash Customization teaching: 10 minutes exercises: 0 questions: diff --git a/_episodes/08-environment-variables.md b/_episodes/07-environment-variables.md similarity index 100% rename from _episodes/08-environment-variables.md rename to _episodes/07-environment-variables.md diff --git a/_episodes/09-commandsubstitution.md b/_episodes/08-command-substitution.md similarity index 79% rename from _episodes/09-commandsubstitution.md rename to _episodes/08-command-substitution.md index 9e3b1ca..f2f96c7 100644 --- a/_episodes/09-commandsubstitution.md +++ b/_episodes/08-command-substitution.md @@ -1,14 +1,18 @@ --- -layout: page -title: The Unix Shell -subtitle: Command Subsitution -minutes: 15 +title: "Command Substitution" +teaching: 10 +exercises: 5 +questions: +- "How to use command substitutions for arguments flexibility?" +objectives: +- Understand the need for flexibility regarding arguments +- Generate the values of the arguments on the fly using command substitution +- Understand the difference between pipes/redirection and the command substitution operator +keypoints: +- Command substitution can achieved by using dollar mark, `$(things to be replaced)`. +- Things to be replaced can be words and outputs of another command +- Command substitution can be used for inputs and output of another command, but the output side must be modified to avoid file replacements. --- -> ## Learning Objectives {.objectives} -> -> * Understand the need for flexibility regarding arguments -> * Generate the values of the arguments on the fly using command substitution -> * Understand the difference between pipes/redirection, and the command substitution operator ## Introduction @@ -39,7 +43,7 @@ $ for cutoff in 0.001 0.01 0.05; do In the second example, the things to loop over: `"0.001 0.01 0.05"` are spelled out by you. -## Looping over the words in a string {.callout} +## Looping over the words in a string > > In the previous example you can make your code neater and self-documenting by putting the cutoff values > in a separate string: @@ -56,10 +60,9 @@ However, you don't always know in advance *what* you have to loop over. It could well be that it is not a simple file name pattern (in which case you can use wildcards), or that it is not a small, known set of values (in which case you can write them out explicitly as was done -in the second example). It would therefore be nice if you could loop +in the second example). It would, therefore be nice if you could loop over filenames or over words contained in a file. Suppose that file -`cohort2010.txt` contains the filenames over which to iterate, then it -would be nice to able to say something like: +`cohort2010.txt` contains the filenames over which to iterate; then it would be nice to able to say something like: ~~~ # (imaginary syntax) @@ -73,7 +76,7 @@ $ for file in [INSERT THE CONTENTS OF cohort2010.txt HERE] This would be more general, more flexible and more tractable than relying on the wildcard mechanism. What we need, therefore, is a -mechanism that actually replaces everytying beween `[` and `]` with the +mechanism that actually replaces everything between `[` and `]` with the desired names of input files, just before the loop starts. Thankfully, this mechanism exists, and it is called the **command substitution operator** (previously written using the **backtick operator**). It looks much like the previous snippet: @@ -96,7 +99,7 @@ replaced with simple spaces. In legacy code, you may see the same construct but with a different syntax. It starts and ends with backticks, `` ` `` (not to be confused with the single quote `'` !). The backticks work exactly the -same as the command substitution done by `$(` and `)`. However its use +same as the command substitution done by `$(` and `)`. However, its use is discouraged as backticks cannot be nested. ## Example @@ -163,17 +166,18 @@ simply because `cat cohort2010.txt | head -n 2` produces Everything between the `$(` and `)` is executed verbatim by the shell, so also the `-n 2` argument to the `head` command works as expected. -### **Important** - -Recall from the *Loops* and the *Shell Scripts* topics that Unix uses -whitespace to separate command, options (flags) and parameters / -arguments. For the same reason it is essential that the command (or -pipeline) inside the backticks produces *clean* output: single word -output works best within single commands and whitespace- or -newline-separated words works best for lists over which to iterate in -loops. - -> ## Generating filenames based on a timestamp {.challenge} +> ## Important +> +> Recall from the *Loops* and the *Shell Scripts* topics that Unix uses +> whitespace to separate command, options (flags) and parameters / +> arguments. For the same reason it is essential that the command (or +> pipeline) inside the backticks produces *clean* output: single word +> output works best within single commands and whitespace- or +> newline-separated words work best for lists over which to iterate in +> loops. +{: .callout} + +> ## Generating filenames based on a timestamp > > It can be useful to create the filename 'on the fly'. For instance, if > some program called `qualitycontrol` is run periodically (or @@ -204,10 +208,9 @@ loops. > few times, waiting a few seconds between invocations (use the arrow-up > key to avoid having to retype the command) +{: .challenge} - -## Juggling filename extensions {.challenge} - +> ## Juggling filename extensions > When running an analysis program with a certain input file, it > is often required that the output has the same name as the input, but with > a different filename extension, e.g. @@ -237,14 +240,13 @@ loops. > ~~~ > but for *each* of the `.pdb`-files. +{: .challenge} ## Closing remarks - -The command subsitution operator provides us with a +The command substitution operator provides us with a powerful new piece of 'plumbing' that allows us to connect "small pieces, loosely together" to keep with the Unix philosophy. It is remotely similar to the `|` operator in the sense that it connects two programs. But there is also a clear difference: `|` connects the standard output of one command to the standard input of another command, -where as `` $(command) `` is substituted 'in-place' into the the shell -script, and always provides parameters, options, arguments to other commands. +where as `` $(command) `` is substituted 'in-place' into the shell script, and always provides parameters, options, and arguments to other commands. diff --git a/_episodes/10_awk.md b/_episodes/09-awk.md similarity index 50% rename from _episodes/10_awk.md rename to _episodes/09-awk.md index 9671e21..57a00df 100644 --- a/_episodes/10_awk.md +++ b/_episodes/09-awk.md @@ -1,36 +1,42 @@ --- -layout: page title: AWK -subtitle: Manipulating and filtering complex data -minutes: 120 +teaching: 20 +exercises: 5 +questions: +- "How to use AWK for text processing?" +objectives: +- "Explain why AWK is useful and when it is better than pipes" +- "Show a basic usage similar to the command `cat` command" +- "Introduce the filed separator parameter" +- "Use regular expressions to perform different instructions" +- "Introduce BEGIN and END keywords" +- "Use the `if-then` structure to change behaviour for the same matching regex" +- "Introduce the array data structure" +- "Use the for loop to cycle through an array" +keypoints: +- awk can be used to manipulate and filter data, e.g. adding text or printing specific columns +- NF is a variable that stores the number of fields in the current line +- Field separator can be specified with the `-F` option, default is space +- Matching patterns can be specified with `/^PATTERN/` instruction --- -> ## Learning Objectives {.objectives} -> -> * Explain why AWK is useful and when it is better than pipes. -> * Show a basic usage similar to the command "cut" -> * Introduce the filed separator parameter. -> * Use regulax expressions to perform different instructions. -> * Introduce BEGIN and END keywords. -> * Use the if then structure to change behaviour for the same matching regex. -> * Introduce the array data structure. -> * Use the for loop to cycle through an array -Prerequisite: shell and any programming language +AWK is a tool for manipulating and filtering complex data. It stands for Aho, Weinberger, and Kernighan, the designers of this program. This chapter requires understanding of previous shell lessons and any programming language. + +Let's start. The `example.txt` for exercise is available under `data` directory. You can also download it from [here](../data/example.txt). -If we need to count the number of lines in a file, we can use the previously -showed command for word counting wc +If we need to count the number of lines in a file, we can use the previously shown command for word counting `wc`. ~~~ {.bash} -$ wc -l example.txt +wc -l example.txt ~~~ As you probably remember, -l is an option that asks for the number of lines only. However, wc counts the number of newlines in the file, if the last line does -not contain a carriage return (i.e. there is no emptyline at the end of the file), +not contain a carriage return (i.e. there is no empty line at the end of the file), the result is going be the actual number of lines minus one. - -A workaround is to use Awk. Awk is command line program that takes as input a set + +A workaround is to use Awk. Awk is a command line program that takes as input a set of instructions and one or more files. The instructions are executed on each line of the input file(s). @@ -39,20 +45,21 @@ The instructions are enclosed in single quotes or they can be read from a file. Example: ~~~ {.bash} -$ awk '{print $0}' example.txt +awk '{print $0}' example.txt ~~~ -This command has the same output of "cat": it prints each line from the example.txt +This command has the same output as `cat`: it prints each line from the example.txt file. The structure of the instruction is the following: + - curly braces surround the set of instructions - print is the instruction that sends its arguments to the terminal - $0 is a variable, it means "the content of the current line" As you can see, the file contains a table. -Awk automatically splits the processed line by looking at spaces: in our case it has +Awk automatically splits the processed line by looking at spaces: in our case, it has knowledge of the different columns in the table. Each column value for the current line is stored into a variable: $1 for the first @@ -61,13 +68,13 @@ column, $2 for the second and so on. So, if we like to print only the second column from the table, we execute ~~~ {.bash} -$ awk '{print $2}' example.txt +awk '{print $2}' example.txt ~~~ -We can also print more than one value, or add text to the printed line: +We can also print more than one value, or add text (e.g. "chr") to the printed line: ~~~ {.bash} -$ awk '{print "chr",$2,$4}' example.txt +awk '{print "chr",$2,$4}' example.txt ~~~ The comma puts a space between the printed values. Strings of text should be enclosed in @@ -82,55 +89,59 @@ Awk helps us thanks to the variable NF. NF stores the number of fields (our colu row. Let's see for our table: ~~~ {.bash} -$ awk '{print NF}' example.txt +awk '{print NF}' example.txt ~~~ We can see that some lines contain 6 fields while others contain 7 of them. Since NF is the number of the last field, $NF contains its value. ~~~ {.bash} -$ awk '{print "This line has",NF,"columns. The last one contains",$NF}' example.txt +awk '{print "This line has",NF,"columns. The last one contains",$NF}' example.txt ~~~ -> ## Field separator {.callout} +> ## Field separator +> > Out there we have different file formats: our data may be comma separated (csv), -> tab separated (tsv), by semicolon or by any other character. +> tab separated (tsv), by a semicolon or by any other character. +{: .callout} -To specify the field separator, we should provide it at command line like: +To specify the field separator, we should provide it at the command line like: ~~~ {.bash} -$ awk -F "," '{print $2}' example2.txt +awk -F "," '{print $2}' example2.txt ~~~ -In this case , we are printing the second field in each line, using comma as separator. +In this case, we are printing the second field in each line, using comma as separator. Please notice that the character space is now part of the field value, since it is no longer the separator. -> ## Matching lines {.callout} -> Maybe we would like to perform different instruction on different lines. +> ## Matching lines +> +> Maybe we would like to perform different instructions on different lines. +{: .callout} Awk allows you to specify a matching pattern, like the command grep does. Let's look at the file content ~~~ {.bash} -$ awk '{print $0}' example.pdb +awk '{print $0}' methane.pdb ~~~ -It seems an abriged PDB file. If we would like to print only lines starting with the word +It seems to be an abridged PDB file. If we would like to print only lines starting with the word "ATOM", we type: ~~~ {.bash} -awk '/^ATOM/ {print $0}' example.pdb +awk '/^ATOM/ {print $0}' methane.pdb ~~~ In this case, we specify the pattern before the instructions: only lines starting with the text "ATOM". As you remember, ^ means "at the beginning of the line". -We can specify more that one pattern: +We can specify more than one pattern: ~~~ {.bash} -awk '/^ATOM/ {print $7,$8,$9} /^HEADER/ {print $NF}' example.pdb +awk '/^ATOM/ {print $7,$8,$9} /^HEADER/ {print $NF}' methane.pdb ~~~ In this case, we are printing the spatial coordinates of each atom. diff --git a/_extras/assets/README.md b/_extras/assets/README.md new file mode 100644 index 0000000..3772213 --- /dev/null +++ b/_extras/assets/README.md @@ -0,0 +1 @@ +Folder for images, etc. diff --git a/_extras/assets/bash-config - osx.png b/_extras/assets/bash-config - osx.png new file mode 100644 index 0000000..c3d3250 Binary files /dev/null and b/_extras/assets/bash-config - osx.png differ diff --git a/_extras/assets/bash-config-ubuntu.png b/_extras/assets/bash-config-ubuntu.png new file mode 100644 index 0000000..dd20b16 Binary files /dev/null and b/_extras/assets/bash-config-ubuntu.png differ diff --git a/_extras/config.md b/_extras/config.md new file mode 100644 index 0000000..ec6058a --- /dev/null +++ b/_extras/config.md @@ -0,0 +1,66 @@ +# Bash Configurations Demystified +.bash_profile, .profile, & .bashrc Conventions + +Bash configurations on Linux and OS X can be confusing for many people, myself included. I've written this short guide to remind you and I both of a reasonable set of conventions you could follow. +Login Shell vs. Non-login Shell + +When logging in via the console (e.g., an SSH session, the scary console login after you've messed up your GUI settings, etc.), you are starting a login shell. If you open a terminal application (e.g. xterm, etc.) from your desktop, then you are starting a non-login shell (except on OS X, discussed later). +Linux (Ubuntu specifically) + +On a clean install of Ubuntu, you'll notice your home directory contains both a .profile and .bashrc file. Starting a login shell executes .profile and starting a non-login shell executes .bashrc. Notice that inside .profile you'll find +``` +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi +``` +This means that login shells execute .profile and then source .bashrc, while non-login shells execute .bashrc only. + +![](assets/ubuntu_bash_diagram.png) + +Be Aware (if you add a .bash_profile) + +You should also be aware that to start a login shell bash looks for .bash_profile, .bash_login, and .profile in that order and it only reads and executes the first one it finds. By default, the first two are not present on Ubuntu. Programs like RVM add a .bash_profile file so you should be sure to append + + [[ -s ${HOME}/.profile ]] && source ${HOME}/.profile + +to the added .bash_profile file. (After installing RVM you might have noticed that ls colorization disappeared from login shells as a result of .bashrc no longer being sourced since .profile was ignored; this should resolve those issues). Sourcing .profile means that now, every time you start a login shell .bash_profile is executed, then .profile, and finally .bashrc. Starting a non-login shell will just execute .bashrc as before. +Mac OS X + +On a clean install of OS X, you should have a .bashrc file and a .bash_profile file. Unlike most of the Unix/Linux world, OS X terminal applications (e.g. Terminal, iTerm2, etc.) start a login shell. So whether you SSH into an OS X machine or launch a terminal application, bash will launch as a login shell. While Ubuntu makes use of .profile by default, OS X chose to use .bash_profile (and no .profile file), which takes precedence on the list given above. Inside the .bash_profile on OS X, you'll find something like + + [[ -s ~/.bashrc ]] && source ~/.bashrc + +Just as Ubuntu's .profile sourced .bashrc, OS X's .bash_profile sources .bashrc too. On OS X, whether you login via a GUI and open a terminal application, SSH in, or login at a console, you'll be starting a login shell which will execute .bash_profile and then source .bashrc. + +![](os_x_bash_diagram.png) + +## Where do I make changes? + +Whether you use Linux or OS X, any bash-related changes, such as adding aliases, functions, or tweaking the prompt appearance can be appended to .bashrc. If you've set up sourcing as described above, .bashrc is executed in both login and non-login shells on both Linux and Mac OS X. + +Another related option is to append + + [[ -s ${HOME}/.local.bash ]] && source ${HOME}/.local.bash + +to .bashrc and then make all further bash customization changes to .local.bash. This seems to be common on company issued machines since admins don't like users mucking around with .bashrc. If this is the case for you, then make your bash config changes to .local.bash. +When NOT to modify .bashrc? + +As the name implies, .bashrc is for bash configs. Environment variables or other configuration settings should typically be written to .profile on Ubuntu and .bash_profile on OS X. A common desire is to extend the PATH variable: + +```` +# Add path to Python scripts directory +PATH=/usr/local/share/python:$PATH +```` + +On Linux, you would append this path extension to your .profile, unless you've set up a .bash_profile that sources .profile which then sources .bashrc (just choose a strategy and be consistent). Logging into your machine again, every terminal session will have the PATH you defined. This happens because .profile (or .bash_profile) is executed at login, before any non-login shells are started. I do most of my PATH modifications when first configuring a machine, so it is no problem to apply changes at the next login. If you need to apply your change now, in your current non-login shell, you could: + + source ~/.profile # or ~/.bash_profile + +On OS X, you should add the line to .bash_profile, although you could optionally set up .bash_profile to source .profile and .bashrc for symetry with Ubuntu and put the line in .profile. +Errors + +If you find any errors or have any suggestions, please kindly contact me at @dghubble or by email at dghubble@gmail.com. I'll keep this updated reference. diff --git a/_extras/help.md b/_extras/help.md new file mode 100644 index 0000000..9c46bef --- /dev/null +++ b/_extras/help.md @@ -0,0 +1,285 @@ +# How to add a help message to shell script + +## About functions + +Shell functions are lists of Bash program statements that are stored in the shell's environment and can be executed, like any other command, by typing their name at the command line. Shell functions may also be known as procedures or subroutines, depending upon which other programming language you are using. + +Functions are called in scripts or from the command-line interface (CLI) by using their names, just as you would for any other command. In a CLI program or a script, the commands in the function execute when they are called, then the program flow sequence returns to the calling entity, and the next series of program statements in that entity executes. + +The syntax of a function is: + + FunctionName(){program statements} + +Explore this by creating a simple function at the CLI. (The function is stored in the shell environment for the shell instance in which it is created.) You are going to create a function called hw, which stands for "hello world." Enter the following code at the CLI and press Enter. Then enter hw as you would any other shell command: + +``` +[student@testvm1 ~]$ hw(){ echo "Hi there kiddo"; } +[student@testvm1 ~]$ hw +Hi there kiddo +[student@testvm1 ~]$About functions +``` + +Shell functions are lists of Bash program statements that are stored in the shell's environment and can be executed, like any other command, by typing their name at the command line. Shell functions may also be known as procedures or subroutines, depending upon which other programming language you are using. + +Functions are called in scripts or from the command-line interface (CLI) by using their names, just as you would for any other command. In a CLI program or a script, the commands in the function execute when they are called, then the program flow sequence returns to the calling entity, and the next series of program statements in that entity executes. + +The syntax of a function is: + + FunctionName(){program statements} + +Explore this by creating a simple function at the CLI. (The function is stored in the shell environment for the shell instance in which it is created.) You are going to create a function called hw, which stands for "hello world." Enter the following code at the CLI and press Enter. Then enter hw as you would any other shell command: + +``` +[student@testvm1 ~]$ hw(){ echo "Hi there kiddo"; } +[student@testvm1 ~]$ hw +Hi there kiddo +[student@testvm1 ~]$ +``` + +OK, so I am a little tired of the standard "Hello world" starter. Now, list all of the currently defined functions. There are a lot of them, so I am showing just the new hw function. When it is called from the command line or within a program, a function performs its programmed task and then exits and returns control to the calling entity, the command line, or the next Bash program statement in a script after the calling statement: + +``` +[student@testvm1 ~]$ declare -f | less + +hw () +{ + echo "Hi there kiddo" +} + +``` + +Remove that function because you do not need it anymore. You can do that with the unset command: + +``` +[student@testvm1 ~]$ unset -f hw ; hw +bash: hw: command not found +[student@testvm1 ~]$ +``` + +## Creating the Help function + +Open the hello program in an editor and add the Help function below to the hello program code after the copyright statement but before the echo "Hello world!" statement. This Help function will display a short description of the program, a syntax diagram, and short descriptions of the available options. Add a call to the Help function to test it and some comment lines that provide a visual demarcation between the functions and the main portion of the program: + +``` +################################################################################ +# Help # +################################################################################ +Help() +{ + # Display Help + echo "Add description of the script functions here." + echo + echo "Syntax: scriptTemplate [-g|h|v|V]" + echo "options:" + echo "g Print the GPL license notification." + echo "h Print this Help." + echo "v Verbose mode." + echo "V Print software version and exit." + echo +} + +################################################################################ +################################################################################ +# Main program # +################################################################################ +################################################################################ + +Help +echo "Hello world!" + +The options described in this Help function are typical for the programs I write, although none are in the code yet. Run the program to test it: + +[student@testvm1 ~]$ ./hello +Add description of the script functions here. + +Syntax: scriptTemplate [-g|h|v|V] +options: +g Print the GPL license notification. +h Print this Help. +v Verbose mode. +V Print software version and exit. + +Hello world! +[student@testvm1 ~]$ +``` + +Because you have not added any logic to display Help only when you need it, the program will always display the Help. Since the function is working correctly, read on to add some logic to display the Help only when the -h option is used when you invoke the program at the command line. + +## Handling options + +A Bash script's ability to handle command-line options such as -h gives some powerful capabilities to direct the program and modify what it does. In the case of the -h option, you want the program to print the Help text to the terminal session and then quit without running the rest of the program. The ability to process options entered at the command line can be added to the Bash script using the while command (see How to program with Bash: Loops to learn more about while) in conjunction with the getops and case commands. + +The getops command reads any and all options specified at the command line and creates a list of those options. In the code below, the while command loops through the list of options by setting the variable $options for each. The case statement is used to evaluate each option in turn and execute the statements in the corresponding stanza. The while statement will continue to evaluate the list of options until they have all been processed or it encounters an exit statement, which terminates the program. + +Be sure to delete the Help function call just before the echo "Hello world!" statement so that the main body of the program now looks like this: +``` +################################################################################ +################################################################################ +# Main program # +################################################################################ +################################################################################ +################################################################################ +# Process the input options. Add options as needed. # +################################################################################ +# Get the options +while getopts ":h" option; do + case $option in + h) # display Help + Help + exit;; + esac +done + +echo "Hello world!" +``` + +Notice the double semicolon at the end of the exit statement in the case option for -h. This is required for each option added to this case statement to delineate the end of each option. + +## Testing + +Testing is now a little more complex. You need to test your program with a number of different options—and no options—to see how it responds. First, test with no options to ensure that it prints "Hello world!" as it should: + +``` +[student@testvm1 ~]$ ./hello +Hello world! +``` + +That works, so now test the logic that displays the Help text: + +``` +[student@testvm1 ~]$ ./hello -h +Add description of the script functions here. + +Syntax: scriptTemplate [-g|h|t|v|V] +options: +g Print the GPL license notification. +h Print this Help. +v Verbose mode. +V Print software version and exit. +``` + +That works as expected, so try some testing to see what happens when you enter some unexpected options: + +``` +[student@testvm1 ~]$ ./hello -x +Hello world! +[student@testvm1 ~]$ ./hello -q +Hello world! +[student@testvm1 ~]$ ./hello -lkjsahdf +Add description of the script functions here. + +Syntax: scriptTemplate [-g|h|t|v|V] +options: +g Print the GPL license notification. +h Print this Help. +v Verbose mode. +V Print software version and exit. + +[student@testvm1 ~]$ +``` + +The program just ignores any options without specific responses without generating any errors. But notice the last entry (with -lkjsahdf for options): because there is an h in the list of options, the program recognizes it and prints the Help text. This testing has shown that the program doesn't have the ability to handle incorrect input and terminate the program if any is detected. + +You can add another case stanza to the case statement to match any option that doesn't have an explicit match. This general case will match anything you have not provided a specific match for. The case statement now looks like this, with the catch-all match of \? as the last case. Any additional specific cases must precede this final one: + +``` +while getopts ":h" option; do + case $option in + h) # display Help + Help + exit;; + \?) # incorrect option + echo "Error: Invalid option" + exit;; + esac +done +``` + +Test the program again using the same options as before and see how it works now. + +## Where you are + +You have accomplished a good amount in this article by adding the capability to process command-line options and a Help procedure. Your Bash script now looks like this: + +``` +#!/usr/bin/bash +################################################################################ +# scriptTemplate # +# # +# Use this template as the beginning of a new program. Place a short # +# description of the script here. # +# # +# Change History # +# 11/11/2019 David Both Original code. This is a template for creating # +# new Bash shell scripts. # +# Add new history entries as needed. # +# # +# # +################################################################################ +################################################################################ +################################################################################ +# # +# Copyright (C) 2007, 2019 David Both # +# LinuxGeek46@both.org # +# # +# This program is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +################################################################################ +################################################################################ +################################################################################ + +################################################################################ +# Help # +################################################################################ +Help() +{ + # Display Help + echo "Add description of the script functions here." + echo + echo "Syntax: scriptTemplate [-g|h|t|v|V]" + echo "options:" + echo "g Print the GPL license notification." + echo "h Print this Help." + echo "v Verbose mode." + echo "V Print software version and exit." + echo +} + +################################################################################ +################################################################################ +# Main program # +################################################################################ +################################################################################ +################################################################################ +# Process the input options. Add options as needed. # +################################################################################ +# Get the options +while getopts ":h" option; do + case $option in + h) # display Help + Help + exit;; + \?) # incorrect option + echo "Error: Invalid option" + exit;; + esac +done + +echo "Hello world!" +``` +Be sure to test this version of the program very thoroughly. Use random inputs and see what happens. You should also try testing valid and invalid options without using the dash (-) in front. + + +Source: https://opensource.com/article/19/12/help-bash-program \ No newline at end of file diff --git a/code/file_info.sh b/code/file_info.sh new file mode 100755 index 0000000..226fd95 --- /dev/null +++ b/code/file_info.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# This script is used to show the number line of a file +# Usage: ./file_info.sh +# Output: has lines and size of + +# Check if the number of arguments is less than 1 +if [ $# -lt 1 ]; then + echo "Usage: ./show_line_number.sh " + exit 1 +fi + + +# Check if the file exists +if [ ! -f $1 ]; then + echo "File not found" + exit 1 +fi + +# Count the number of lines in the file +line_number=$(wc -l < $1) + +# Count the size of the file +size=$(du -h $1 | cut -f1) + +# Display the filename, number of lines and size of the file +echo "$1 has $line_number lines and size of $size" diff --git a/data/README.md b/data/README.md new file mode 100644 index 0000000..7044edb --- /dev/null +++ b/data/README.md @@ -0,0 +1,7 @@ +# Directory for data used in Shell Extras + +Data (filname: source): + +- example.txt: +- example2.txt: +- methane.pdb: SW Carpentry Shell Novice, shell-lesson-data/exercise/alkanes diff --git a/data/example.txt b/data/example.txt new file mode 100644 index 0000000..3841968 --- /dev/null +++ b/data/example.txt @@ -0,0 +1,11 @@ +CREDITS,EXPDATE,USER,GROUPS +99,01 jun 2018,sylvain,team:::admin +52,01 dec 2018,sonia,team +52,01 dec 2018,sonia,team +25,01 jan 2019,sonia,team +10,01 jan 2019,sylvain,team:::admin +8,12 jun 2018,öle,team:support + + + +17,05 apr 2019,abhishek,guest \ No newline at end of file diff --git a/data/example2.txt b/data/example2.txt new file mode 100644 index 0000000..7290757 --- /dev/null +++ b/data/example2.txt @@ -0,0 +1,241 @@ +file,emotion,speaker,gender +./Actor_21/03-01-07-01-01-01-21.wav,disgust,21,male +./Actor_21/03-01-06-01-02-02-21.wav,fear,21,male +./Actor_21/03-01-06-02-01-02-21.wav,fear,21,male +./Actor_21/03-01-04-02-01-02-21.wav,sad,21,male +./Actor_21/03-01-01-01-01-02-21.wav,neutral,21,male +./Actor_21/03-01-04-01-01-02-21.wav,sad,21,male +./Actor_21/03-01-06-02-01-01-21.wav,fear,21,male +./Actor_21/03-01-03-01-01-02-21.wav,happy,21,male +./Actor_21/03-01-01-01-02-02-21.wav,neutral,21,male +./Actor_21/03-01-03-01-01-01-21.wav,happy,21,male +./Actor_21/03-01-06-01-02-01-21.wav,fear,21,male +./Actor_21/03-01-05-01-01-02-21.wav,angry,21,male +./Actor_21/03-01-02-01-01-02-21.wav,calm,21,male +./Actor_21/03-01-05-01-01-01-21.wav,angry,21,male +./Actor_21/03-01-04-01-02-02-21.wav,sad,21,male +./Actor_21/03-01-07-01-01-02-21.wav,disgust,21,male +./Actor_21/03-01-03-02-01-01-21.wav,happy,21,male +./Actor_21/03-01-01-01-01-01-21.wav,neutral,21,male +./Actor_21/03-01-07-01-02-01-21.wav,disgust,21,male +./Actor_21/03-01-02-01-02-02-21.wav,calm,21,male +./Actor_21/03-01-07-02-02-01-21.wav,disgust,21,male +./Actor_21/03-01-05-02-01-02-21.wav,angry,21,male +./Actor_21/03-01-02-02-01-02-21.wav,calm,21,male +./Actor_21/03-01-06-02-02-02-21.wav,fear,21,male +./Actor_21/03-01-05-01-02-01-21.wav,angry,21,male +./Actor_21/03-01-04-02-02-02-21.wav,sad,21,male +./Actor_21/03-01-01-01-02-01-21.wav,neutral,21,male +./Actor_21/03-01-03-01-02-01-21.wav,happy,21,male +./Actor_21/03-01-07-02-01-02-21.wav,disgust,21,male +./Actor_21/03-01-08-01-02-02-21.wav,surprise,21,male +./Actor_21/03-01-05-02-01-01-21.wav,angry,21,male +./Actor_21/03-01-08-02-02-01-21.wav,surprise,21,male +./Actor_21/03-01-06-01-01-01-21.wav,fear,21,male +./Actor_21/03-01-05-02-02-02-21.wav,angry,21,male +./Actor_21/03-01-04-01-02-01-21.wav,sad,21,male +./Actor_21/03-01-04-02-01-01-21.wav,sad,21,male +./Actor_21/03-01-06-02-02-01-21.wav,fear,21,male +./Actor_21/03-01-02-02-02-01-21.wav,calm,21,male +./Actor_21/03-01-08-02-01-01-21.wav,surprise,21,male +./Actor_21/03-01-08-01-01-02-21.wav,surprise,21,male +./Actor_21/03-01-05-02-02-01-21.wav,angry,21,male +./Actor_21/03-01-08-01-02-01-21.wav,surprise,21,male +./Actor_21/03-01-08-02-01-02-21.wav,surprise,21,male +./Actor_21/03-01-03-01-02-02-21.wav,happy,21,male +./Actor_21/03-01-07-01-02-02-21.wav,disgust,21,male +./Actor_21/03-01-08-01-01-01-21.wav,surprise,21,male +./Actor_21/03-01-02-02-02-02-21.wav,calm,21,male +./Actor_21/03-01-02-02-01-01-21.wav,calm,21,male +./Actor_21/03-01-02-01-02-01-21.wav,calm,21,male +./Actor_21/03-01-08-02-02-02-21.wav,surprise,21,male +./Actor_21/03-01-04-02-02-01-21.wav,sad,21,male +./Actor_21/03-01-06-01-01-02-21.wav,fear,21,male +./Actor_21/03-01-07-02-02-02-21.wav,disgust,21,male +./Actor_21/03-01-03-02-02-02-21.wav,happy,21,male +./Actor_21/03-01-04-01-01-01-21.wav,sad,21,male +./Actor_21/03-01-02-01-01-01-21.wav,calm,21,male +./Actor_21/03-01-07-02-01-01-21.wav,disgust,21,male +./Actor_21/03-01-03-02-02-01-21.wav,happy,21,male +./Actor_21/03-01-03-02-01-02-21.wav,happy,21,male +./Actor_21/03-01-05-01-02-02-21.wav,angry,21,male +./Actor_23/03-01-03-02-01-02-23.wav,happy,23,male +./Actor_23/03-01-02-01-01-02-23.wav,calm,23,male +./Actor_23/03-01-04-01-01-02-23.wav,sad,23,male +./Actor_23/03-01-07-02-02-02-23.wav,disgust,23,male +./Actor_23/03-01-05-02-02-01-23.wav,angry,23,male +./Actor_23/03-01-06-01-01-02-23.wav,fear,23,male +./Actor_23/03-01-08-01-01-02-23.wav,surprise,23,male +./Actor_23/03-01-06-02-01-01-23.wav,fear,23,male +./Actor_23/03-01-05-02-02-02-23.wav,angry,23,male +./Actor_23/03-01-05-01-02-02-23.wav,angry,23,male +./Actor_23/03-01-02-01-01-01-23.wav,calm,23,male +./Actor_23/03-01-07-01-02-01-23.wav,disgust,23,male +./Actor_23/03-01-01-01-02-01-23.wav,neutral,23,male +./Actor_23/03-01-03-02-02-02-23.wav,happy,23,male +./Actor_23/03-01-07-01-01-02-23.wav,disgust,23,male +./Actor_23/03-01-01-01-01-02-23.wav,neutral,23,male +./Actor_23/03-01-01-01-01-01-23.wav,neutral,23,male +./Actor_23/03-01-02-02-02-01-23.wav,calm,23,male +./Actor_23/03-01-05-02-01-02-23.wav,angry,23,male +./Actor_23/03-01-07-02-02-01-23.wav,disgust,23,male +./Actor_23/03-01-08-01-01-01-23.wav,surprise,23,male +./Actor_23/03-01-03-02-01-01-23.wav,happy,23,male +./Actor_23/03-01-08-02-01-02-23.wav,surprise,23,male +./Actor_23/03-01-03-01-02-02-23.wav,happy,23,male +./Actor_23/03-01-08-02-02-02-23.wav,surprise,23,male +./Actor_23/03-01-06-01-01-01-23.wav,fear,23,male +./Actor_23/03-01-07-01-01-01-23.wav,disgust,23,male +./Actor_23/03-01-08-02-01-01-23.wav,surprise,23,male +./Actor_23/03-01-02-02-01-01-23.wav,calm,23,male +./Actor_23/03-01-03-01-02-01-23.wav,happy,23,male +./Actor_23/03-01-05-01-02-01-23.wav,angry,23,male +./Actor_23/03-01-02-01-02-02-23.wav,calm,23,male +./Actor_23/03-01-04-02-02-02-23.wav,sad,23,male +./Actor_23/03-01-06-02-02-01-23.wav,fear,23,male +./Actor_23/03-01-06-01-02-02-23.wav,fear,23,male +./Actor_23/03-01-05-01-01-01-23.wav,angry,23,male +./Actor_23/03-01-04-01-02-01-23.wav,sad,23,male +./Actor_23/03-01-01-01-02-02-23.wav,neutral,23,male +./Actor_23/03-01-07-02-01-01-23.wav,disgust,23,male +./Actor_23/03-01-04-02-01-01-23.wav,sad,23,male +./Actor_23/03-01-08-01-02-01-23.wav,surprise,23,male +./Actor_23/03-01-03-01-01-02-23.wav,happy,23,male +./Actor_23/03-01-07-01-02-02-23.wav,disgust,23,male +./Actor_23/03-01-02-01-02-01-23.wav,calm,23,male +./Actor_23/03-01-06-01-02-01-23.wav,fear,23,male +./Actor_23/03-01-05-01-01-02-23.wav,angry,23,male +./Actor_23/03-01-06-02-01-02-23.wav,fear,23,male +./Actor_23/03-01-02-02-01-02-23.wav,calm,23,male +./Actor_23/03-01-04-02-02-01-23.wav,sad,23,male +./Actor_23/03-01-04-02-01-02-23.wav,sad,23,male +./Actor_23/03-01-05-02-01-01-23.wav,angry,23,male +./Actor_23/03-01-07-02-01-02-23.wav,disgust,23,male +./Actor_23/03-01-02-02-02-02-23.wav,calm,23,male +./Actor_23/03-01-04-01-01-01-23.wav,sad,23,male +./Actor_23/03-01-06-02-02-02-23.wav,fear,23,male +./Actor_23/03-01-03-01-01-01-23.wav,happy,23,male +./Actor_23/03-01-04-01-02-02-23.wav,sad,23,male +./Actor_23/03-01-03-02-02-01-23.wav,happy,23,male +./Actor_23/03-01-08-02-02-01-23.wav,surprise,23,male +./Actor_23/03-01-08-01-02-02-23.wav,surprise,23,male +./Actor_22/03-01-02-01-01-01-22.wav,calm,22,female +./Actor_22/03-01-05-01-02-01-22.wav,angry,22,female +./Actor_22/03-01-03-02-01-02-22.wav,happy,22,female +./Actor_22/03-01-04-01-02-01-22.wav,sad,22,female +./Actor_22/03-01-05-02-02-02-22.wav,angry,22,female +./Actor_22/03-01-08-02-02-02-22.wav,surprise,22,female +./Actor_22/03-01-04-02-02-02-22.wav,sad,22,female +./Actor_22/03-01-02-01-02-02-22.wav,calm,22,female +./Actor_22/03-01-03-02-01-01-22.wav,happy,22,female +./Actor_22/03-01-06-01-01-01-22.wav,fear,22,female +./Actor_22/03-01-07-01-01-02-22.wav,disgust,22,female +./Actor_22/03-01-04-02-01-01-22.wav,sad,22,female +./Actor_22/03-01-07-01-02-02-22.wav,disgust,22,female +./Actor_22/03-01-04-02-02-01-22.wav,sad,22,female +./Actor_22/03-01-06-01-01-02-22.wav,fear,22,female +./Actor_22/03-01-03-02-02-02-22.wav,happy,22,female +./Actor_22/03-01-07-02-01-01-22.wav,disgust,22,female +./Actor_22/03-01-08-02-01-02-22.wav,surprise,22,female +./Actor_22/03-01-01-01-02-01-22.wav,neutral,22,female +./Actor_22/03-01-03-02-02-01-22.wav,happy,22,female +./Actor_22/03-01-03-01-01-01-22.wav,happy,22,female +./Actor_22/03-01-05-02-01-01-22.wav,angry,22,female +./Actor_22/03-01-08-01-02-01-22.wav,surprise,22,female +./Actor_22/03-01-03-01-01-02-22.wav,happy,22,female +./Actor_22/03-01-02-01-02-01-22.wav,calm,22,female +./Actor_22/03-01-05-02-02-01-22.wav,angry,22,female +./Actor_22/03-01-06-02-02-02-22.wav,fear,22,female +./Actor_22/03-01-03-01-02-02-22.wav,happy,22,female +./Actor_22/03-01-05-02-01-02-22.wav,angry,22,female +./Actor_22/03-01-01-01-01-02-22.wav,neutral,22,female +./Actor_22/03-01-07-01-01-01-22.wav,disgust,22,female +./Actor_22/03-01-04-01-01-01-22.wav,sad,22,female +./Actor_22/03-01-02-02-01-01-22.wav,calm,22,female +./Actor_22/03-01-06-01-02-01-22.wav,fear,22,female +./Actor_22/03-01-02-02-02-02-22.wav,calm,22,female +./Actor_22/03-01-08-02-01-01-22.wav,surprise,22,female +./Actor_22/03-01-08-01-02-02-22.wav,surprise,22,female +./Actor_22/03-01-02-02-01-02-22.wav,calm,22,female +./Actor_22/03-01-02-01-01-02-22.wav,calm,22,female +./Actor_22/03-01-05-01-01-02-22.wav,angry,22,female +./Actor_22/03-01-04-01-01-02-22.wav,sad,22,female +./Actor_22/03-01-08-01-01-01-22.wav,surprise,22,female +./Actor_22/03-01-06-02-01-02-22.wav,fear,22,female +./Actor_22/03-01-07-02-02-01-22.wav,disgust,22,female +./Actor_22/03-01-06-02-02-01-22.wav,fear,22,female +./Actor_22/03-01-06-02-01-01-22.wav,fear,22,female +./Actor_22/03-01-07-02-01-02-22.wav,disgust,22,female +./Actor_22/03-01-08-01-01-02-22.wav,surprise,22,female +./Actor_22/03-01-01-01-02-02-22.wav,neutral,22,female +./Actor_22/03-01-06-01-02-02-22.wav,fear,22,female +./Actor_22/03-01-02-02-02-01-22.wav,calm,22,female +./Actor_22/03-01-05-01-01-01-22.wav,angry,22,female +./Actor_22/03-01-03-01-02-01-22.wav,happy,22,female +./Actor_22/03-01-01-01-01-01-22.wav,neutral,22,female +./Actor_22/03-01-04-01-02-02-22.wav,sad,22,female +./Actor_22/03-01-05-01-02-02-22.wav,angry,22,female +./Actor_22/03-01-04-02-01-02-22.wav,sad,22,female +./Actor_22/03-01-08-02-02-01-22.wav,surprise,22,female +./Actor_22/03-01-07-02-02-02-22.wav,disgust,22,female +./Actor_22/03-01-07-01-02-01-22.wav,disgust,22,female +./Actor_24/03-01-02-02-01-01-24.wav,calm,24,female +./Actor_24/03-01-05-02-01-01-24.wav,angry,24,female +./Actor_24/03-01-01-01-01-01-24.wav,neutral,24,female +./Actor_24/03-01-07-01-01-01-24.wav,disgust,24,female +./Actor_24/03-01-05-02-02-01-24.wav,angry,24,female +./Actor_24/03-01-03-01-01-01-24.wav,happy,24,female +./Actor_24/03-01-05-02-01-02-24.wav,angry,24,female +./Actor_24/03-01-02-01-01-01-24.wav,calm,24,female +./Actor_24/03-01-02-01-02-02-24.wav,calm,24,female +./Actor_24/03-01-05-02-02-02-24.wav,angry,24,female +./Actor_24/03-01-06-01-02-02-24.wav,fear,24,female +./Actor_24/03-01-03-02-02-02-24.wav,happy,24,female +./Actor_24/03-01-07-02-02-01-24.wav,disgust,24,female +./Actor_24/03-01-04-02-01-01-24.wav,sad,24,female +./Actor_24/03-01-01-01-02-02-24.wav,neutral,24,female +./Actor_24/03-01-02-01-02-01-24.wav,calm,24,female +./Actor_24/03-01-08-01-02-01-24.wav,surprise,24,female +./Actor_24/03-01-06-02-02-02-24.wav,fear,24,female +./Actor_24/03-01-07-02-02-02-24.wav,disgust,24,female +./Actor_24/03-01-04-01-01-01-24.wav,sad,24,female +./Actor_24/03-01-06-01-01-02-24.wav,fear,24,female +./Actor_24/03-01-03-02-01-02-24.wav,happy,24,female +./Actor_24/03-01-04-02-01-02-24.wav,sad,24,female +./Actor_24/03-01-05-01-02-01-24.wav,angry,24,female +./Actor_24/03-01-05-01-02-02-24.wav,angry,24,female +./Actor_24/03-01-06-02-02-01-24.wav,fear,24,female +./Actor_24/03-01-01-01-02-01-24.wav,neutral,24,female +./Actor_24/03-01-04-01-02-02-24.wav,sad,24,female +./Actor_24/03-01-02-02-01-02-24.wav,calm,24,female +./Actor_24/03-01-01-01-01-02-24.wav,neutral,24,female +./Actor_24/03-01-03-01-02-02-24.wav,happy,24,female +./Actor_24/03-01-08-01-01-01-24.wav,surprise,24,female +./Actor_24/03-01-06-01-02-01-24.wav,fear,24,female +./Actor_24/03-01-03-02-02-01-24.wav,happy,24,female +./Actor_24/03-01-06-01-01-01-24.wav,fear,24,female +./Actor_24/03-01-06-02-01-02-24.wav,fear,24,female +./Actor_24/03-01-02-01-01-02-24.wav,calm,24,female +./Actor_24/03-01-03-01-02-01-24.wav,happy,24,female +./Actor_24/03-01-07-02-01-02-24.wav,disgust,24,female +./Actor_24/03-01-06-02-01-01-24.wav,fear,24,female +./Actor_24/03-01-05-01-01-01-24.wav,angry,24,female +./Actor_24/03-01-08-02-02-02-24.wav,surprise,24,female +./Actor_24/03-01-02-02-02-01-24.wav,calm,24,female +./Actor_24/03-01-08-01-02-02-24.wav,surprise,24,female +./Actor_24/03-01-07-01-02-01-24.wav,disgust,24,female +./Actor_24/03-01-04-01-02-01-24.wav,sad,24,female +./Actor_24/03-01-07-02-01-01-24.wav,disgust,24,female +./Actor_24/03-01-08-02-01-01-24.wav,surprise,24,female +./Actor_24/03-01-04-02-02-02-24.wav,sad,24,female +./Actor_24/03-01-04-02-02-01-24.wav,sad,24,female +./Actor_24/03-01-07-01-01-02-24.wav,disgust,24,female +./Actor_24/03-01-02-02-02-02-24.wav,calm,24,female +./Actor_24/03-01-05-01-01-02-24.wav,angry,24,female +./Actor_24/03-01-04-01-01-02-24.wav,sad,24,female +./Actor_24/03-01-07-01-02-02-24.wav,disgust,24,female +./Actor_24/03-01-03-02-01-01-24.wav,happy,24,female +./Actor_24/03-01-08-02-02-01-24.wav,surprise,24,female +./Actor_24/03-01-08-01-01-02-24.wav,surprise,24,female +./Actor_24/03-01-03-01-01-02-24.wav,happy,24,female +./Actor_24/03-01-08-02-01-02-24.wav,surprise,24,female diff --git a/data/methane.pdb b/data/methane.pdb new file mode 100644 index 0000000..7908351 --- /dev/null +++ b/data/methane.pdb @@ -0,0 +1,9 @@ +COMPND METHANE +AUTHOR DAVE WOODCOCK 95 12 18 +ATOM 1 C 1 0.257 -0.363 0.000 1.00 0.00 +ATOM 2 H 1 0.257 0.727 0.000 1.00 0.00 +ATOM 3 H 1 0.771 -0.727 0.890 1.00 0.00 +ATOM 4 H 1 0.771 -0.727 -0.890 1.00 0.00 +ATOM 5 H 1 -0.771 -0.727 0.000 1.00 0.00 +TER 6 1 +END