From e472931b88d418a3f0682e06165e9601a91365b7 Mon Sep 17 00:00:00 2001 From: Jacques Dainat <jacques.dainat@ird.fr> Date: Thu, 7 Mar 2024 12:31:36 +0100 Subject: [PATCH] externalize setup folder structure --- docs/pages/bash/bash-0-setup.md | 19 ++++++++++++ docs/pages/bash/bash-2-the-basics.md | 4 +++ docs/pages/bash/bash-3-navigating.md | 29 ++++++------------- ...sh-4-working_with_files_and_directories.md | 11 +++++-- 4 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 docs/pages/bash/bash-0-setup.md diff --git a/docs/pages/bash/bash-0-setup.md b/docs/pages/bash/bash-0-setup.md new file mode 100644 index 0000000..76a1215 --- /dev/null +++ b/docs/pages/bash/bash-0-setup.md @@ -0,0 +1,19 @@ +### Setup + + +First copy and paste this command to execute it. No worries not need to understand what it does. + +```bash +course={{extra.working_directory}} +mkdir -p ~/$course/script +mkdir -p ~/$course/data +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 +touch ~/$course/data/dataB.fastq +cd $course +echo "done" +``` + +The command above prepare a {{extra.working_directory}} directory with material. diff --git a/docs/pages/bash/bash-2-the-basics.md b/docs/pages/bash/bash-2-the-basics.md index 65386d0..c487975 100644 --- a/docs/pages/bash/bash-2-the-basics.md +++ b/docs/pages/bash/bash-2-the-basics.md @@ -71,6 +71,10 @@ Bash is often preferred over other shells for many reasons: ## The Unix directory structure +{% + include-markdown "pages/bash/bash-0-setup.md" +%} + **/ – The root directory** Everything, all the files and directories, in Linux are located under `root` represented by `/`. If you look at the directory structure, you’ll realize that it is similar to a plant’s root. diff --git a/docs/pages/bash/bash-3-navigating.md b/docs/pages/bash/bash-3-navigating.md index 1429494..c0097fb 100644 --- a/docs/pages/bash/bash-3-navigating.md +++ b/docs/pages/bash/bash-3-navigating.md @@ -2,25 +2,11 @@ Back to the directory structure... this time we will learn to `navigate between directories` and the difference between **absolute** and **relative** paths. -## Prepare +??? quote "First click and follow the instructions below only if you start the course at this stage! Otherwise skip this step!" + {% + include-markdown "pages/bash/bash-0-setup.md" + %} -Back to the directory structure... this time we will learn difference between **absolute** and **relative** path and use a few commands in process. - -First copy and paste this command to execute it. No worries not need to understand what it does. - -```bash -course={{extra.working_directory}} -mkdir -p ~/$course/script -mkdir -p ~/$course/data -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 -touch ~/$course/data/dataB.fastq -echo "done" -``` - -The command above prepare a {{extra.working_directory}} directory with material. ## Where are we? @@ -121,7 +107,7 @@ To move into a directory we have seen we can use the command `cd` and a director ## Relative path -A `relative`` path is a path that specifies the location of a file or directory with respect to the current working directory. Any path that does not begin with a separator character ("/") is a relative path. +A `relative` path is a path that specifies the location of a file or directory with respect to the current working directory. Any path that does not begin with a separator character ("/") is a relative path. !!! tip Relative path: @@ -190,12 +176,15 @@ We are now in the `script` directory. 1. cd . 2. cd .. 3. cd ../.. - 4. cd /home/<userName> + 4. cd /home/<userName\> 5. cd ~ 6. cd home 7. cd ~/data/.. 9. cd / +??? example "Click to show the solution" + 3,4,5 + ## File path Autocompletion It exist a wonderful behavior in Bash called the autocompletion. What it is? 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 4f63def..f987b48 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 @@ -1,7 +1,14 @@ # Working with files and directories -In theory you should be in the `script` directory. -Check using `pwd` and if it is not the case run `cd ~/{{extra.working_directory}}/script` +??? quote "First click and follow the instructions below only if you start the course at this stage! Otherwise skip this step!" + {% + include-markdown "pages/bash/bash-0-setup.md" + %} + +Let's be sure to be in the `script` directory before to continue the rest of the training: +```bash +cd ~/{{extra.working_directory}}/script +``` {: style="height:250px"} -- GitLab