Skip to content
Snippets Groups Projects
Commit 0a9f23f3 authored by jacques.dainat_ird.fr's avatar jacques.dainat_ird.fr
Browse files

update

parent 407e0f32
No related branches found
No related tags found
No related merge requests found
Pipeline #2526 passed
......@@ -12,7 +12,7 @@ First copy and paste this command to execute it. No worries not need to understa
course={{extra.working_directory}}
mkdir -p ~/$course/script
mkdir -p ~/$course/data
touch ~/$course/README
echo "Welcome to the {{extra.working_directory}} course" > ~/$course/README
echo "echo hello" > ~/$course/script/script1.sh
echo "ATGC" > ~/$course/data/data1.fa
touch ~/$course/data/dataA.fastq
......
......@@ -84,11 +84,11 @@ We can observe in the variable case, it's value is printed, while it was not the
In the second example the litteral value `(` is printed.
### Escaping
Not from the room...
In bash it exists a special character allowing to escape a special character. ![](../images/tips/Unknown.jpeg){: style="height:100px"}
You can avoid a special character to be interpreted as "special" by adding a backslash `\`.
![](../images/tips/Unknown.jpeg){: style="height:100px" align=right}
Not from the room...
In bash it exists a *special character allowing to escape a special character*.
You can avoid a special character to be interpreted as "special" by adding a backslash `\`.
Let's give a try to make it clearer:
```bash
......
# The PATH variable
The PATH environment variable (variable available by all shells) is very important, it specifies the directories to be searched to find a command absent from bash itself.
The **PATH** environment variable (variable available by all shells) is very important, it specifies the directories to be searched to find a command absent from bash itself.
When calling a tool, Bash will first look among commands shipped with him, then look at your current directory, and finally will look in order in all directories listed un the PATH variable.
It is how your computer access tools. There is no magic. The computer is just following some simple rules. If you call a tool unknown by Bash and not part of any path listed in $PATH, there is no way for your computer to guess where it is and will tell you `command not found`.
......@@ -34,6 +34,6 @@ The paths are listed using the `:` separator.
!!! Success "Quick recap"
In this section we've learned:
- the PATH variable
- the PATH variable
- the logic how a command or a tool is found on the computer
# Commands
Bash 4.3 comes with 58 embeded commands:
## Commands
```
bash defines the following built-in commands: :, ., [, alias, bg, bind, break, builtin,
case, cd, command, compgen, complete, continue, declare, dirs, disown, echo, enable, eval,
exec, exit, export, fc, fg, getopts, hash, help, history, if, jobs, kill, let, local,
logout, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt, source,
suspend, test, times, trap, type, typeset, ulimit, umask, unalias, unset, until, wait,
while.
```
###
1 commands, 2 coomadns etc.. pipe
They are built-in for performance reasons.
There are many more commands available on your machine. Unix machines have several hundreds of different commands.
A good place to look at them is ([http://ss64.com/mac](http://ss64.com/mac) or [http://ss64.com/bash](http://ss64.com/bash).
save command results in a variavle
var=$(pwd)
**No worries! As most of people we only need to use a very small subset of those commands.**
### I/O of commmands
## How commands works
```bash
command [ -option ] [ arguments ]
```
* [ ] means this is optional (e.g. `ls` vs `ls -l`)
* **Option** only modify the behavior of the command. It starts with `-` (or `--` for long option)
* **Argument** controls the output of the command. It specifies a target for the command.
It is possible to execute several commands in one line using **;** in between commands:
```bash
command1 ; command2
```
It is possible to save the output of a command in a variable:
```bash
var=$(command)
```
### Input/Output of commmands
Commands can take different arguments:
** Nothing **
```bash
ls
```
** String **
```bash
echo hello world
```
** File **
```bash
cat file_input
```
** A stream **
What is a stream?
explanation here
```bash
cat file_input | tr a-z A-Z
```
It is possible to send the output (STDOUT) of a command as input (STDIN) of another using **|**:
```bash
command1 | command2
```
It is possible to save/send the output of a command in a file:
```bash
# overwrite file if already exists
command > file
# append file if already exists
command >> file
```
/!\\ commmands that take an input either from a **file** of from **STDIN**: grep, sed, cat, head, sort, wc, etc.
/!\\ commmands that **never read STDIN**: ls, cp, mv, date, who, pwd, echo, cd, etc.
/!\\ commmands that **read only STDIN**: tr
### Command pipes
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment