diff --git a/docs/pages/bash/bash-4-working_with_files_and_directories.md b/docs/pages/bash/bash-4-working_with_files_and_directories.md index f987b4845ea216915d5abb3cdd8c344152fc79e7..7ef1fa894f88eddb2c94dc977c055cd7ae2b95d8 100644 --- a/docs/pages/bash/bash-4-working_with_files_and_directories.md +++ b/docs/pages/bash/bash-4-working_with_files_and_directories.md @@ -57,7 +57,7 @@ You will end up in a window that represent the inside of your file, with the cur {: style="height:250px"} -Try to display the help `^G`. Not easy isnt'it? But it is like that, no way to make it easier... Depending the command line editor the command that can be executed and their key combinations differ. With nano what is conveniant it's that we do not need a command cheatsheets, the commands are described before our very eyes. +Try to display the help `^G`. Not easy isnt'it? But it is like that, no way to make it easier... Depending the command line editor the command that can be executed and their key combinations differ. The great thing about `**nano** is that you do not need a cheat sheet of commands, they are right there in front of you. Let's now write someting: `I love guacamole` and save the result with `^O` @@ -145,24 +145,36 @@ Let's practice a bit more and by trying to copy the entire `script` folder this ### Your first globbing -Before running you analysis you also need some data. Let's copy in the fastq files present in the `data` folder. +Before running your analysis you also need some data. Let's copy in the fastq files present in the `data` folder. You could use the `cp` command for all the files one by one as we have seen previously. But imagine you have hundred of those `fastq` files? Well Bash does carry out a very powerful feature, the `filename expansion`, a process known as globbing! (to not confound with regular expressions). -Here the list of globbing: +**Here the list of globbing:** -`?` Any single character -`*` Zero or more characters -`[]` Specify a range. Any character of the range or none of them by using ! inside the bracket. -`{term1,term2}` Specify a list of terms separated by commas and each term must be a name or a -wildcard. -`{term1..term2}` Called brace expansion, this syntax -expands all the terms between term1 and term2 (Letters or Integers). +| wildcard characters | meaning | +| :-: | :-: | +| `?` | Any single character | +| `*` | Zero or more characters | +| `[]` | Specify a range. Any character of the range or none of them by using `!` inside the bracket.| +| `{term1,term2}` | Specify a list of terms separated by commas and each term must be a name or a wildcard.| +|Â `{term1..term2}` | Called brace expansion, this syntax expands all the terms between term1 and term2 (Letters or Integers).| -For now you just has to rember the most important one, `*`. +!!! question "Using `ls` how would you list the fastq files available in the `data` folder (and only the fastq files!) ?" -Let's now copy the fastq files using the `*` filename expansion. +??? example "Click to show the solution" + ```bash + ls ../data/data?.fastq + ``` + This one works but if we had a file called `dataPE.fastq` it would not appear because only a single character is expected between `data` and `.fastq` while here it would be `PE`. + ```bash + ls ../data/*.fastq + ``` + Excellent this one match all files ending in `.fastq`. + +For now the most important one you have to rember is `*`. + +Let's now copy all the fastq files using a single command thanks to the `*` filename expansion. ??? example "Click to show the solution" ```bash @@ -268,7 +280,7 @@ ln existing_file [hard_link_name] ln ../data/data1.fa data1_hard.fa ``` Run again `ls -l`. - The second column is the number of hard links to the file. (For a directory, the number of hard links is the number of immediate subdirectories it has plus its parent directory and itself) We can see that we have currrently 3 "files" pointing to the same inode. + The second column is the number of hard links to the file. (For a directory, the number of hard links is the number of immediate subdirectories it has plus its parent directory and itself) We can see that we have currently 3 "files" pointing to the same inode. ### Soft link @@ -291,7 +303,7 @@ ln -s existing_file [soft_link_name] Run `ls -l`. What do you see? ??? example "Click to show the solution" There is an extra arrow showing to what file my link point to. - Create a Hard link of the `script/script1.sh` file and run again `ls -l` + Create a Soft link of the `script/script1.sh` file and run again `ls -l` ??? example "Click to show the solution" ```bash ln -s ../data/data1.fa diff --git a/docs/pages/images/2-basics/.DS_Store b/docs/pages/images/2-basics/.DS_Store deleted file mode 100644 index 41eff97c574529593773d0f9cb9aef6108122a08..0000000000000000000000000000000000000000 Binary files a/docs/pages/images/2-basics/.DS_Store and /dev/null differ