From bd7c90ebddf49dabcab6e511c3bed3a733ec83ca Mon Sep 17 00:00:00 2001 From: Holger Dinkel <dinkel@embl.de> Date: Tue, 24 Feb 2015 12:06:42 +0100 Subject: [PATCH] add more exercises: "Putting it all together" --- sphinx_beginner/exercises_beginner.rst | 15 +++++++++++++ sphinx_beginner/solutions_beginner.rst | 31 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/sphinx_beginner/exercises_beginner.rst b/sphinx_beginner/exercises_beginner.rst index 4de18ff..6c90c7a 100644 --- a/sphinx_beginner/exercises_beginner.rst +++ b/sphinx_beginner/exercises_beginner.rst @@ -135,6 +135,21 @@ IO and Redirections B. Next, use the :ref:`pipe <pipe>` symbol (`|`) and `sort` to sort this output *numerically* +Putting it all together +----------------------- + +#. Create a new directory named ``myscripts`` in your homedirectory + +#. Create an empty file named ``mydate`` in the newly created directory + +#. Add the directory ``~/myscripts`` to your ``PATH`` environment variable + +#. Use ``echo`` in combination with Redirection/Append to write ''date'' into the file ``~/myscripts/mydate`` + +#. Change the permissions of the file ``mydate`` to be executable by you (and you only) + +#. Run the file ``mydate`` (it should print the current date & time). Make sure you can run it from any directory (change to your homedirectory and just type ``mydate``). + Bioinformatics -------------- diff --git a/sphinx_beginner/solutions_beginner.rst b/sphinx_beginner/solutions_beginner.rst index 04010ba..60a520b 100644 --- a/sphinx_beginner/solutions_beginner.rst +++ b/sphinx_beginner/solutions_beginner.rst @@ -273,6 +273,37 @@ IO and Redirections $ cut -f3 -d':' /etc/passwd | sort -n +Putting it all together +----------------------- + +#. Create a new directory named ``myscripts`` in your homedirectory:: + + $ mkdir ~/myscripts + +#. Create an empty file named ``mydate`` in the newly created directory:: + + $ touch ~/myscripts/mydate + +#. Add the directory ``~/myscripts`` to your ``PATH`` environment variable:: + + $ export PATH=$PATH:~/myscripts + +#. Use ``echo`` in combination with Redirection/Append to write ''date'' into the file ``~/myscripts/mydate``:: + + $ echo "date" >> ~/myscripts/mydate + +#. Change the permissions of the file ``mydate`` to be executable by you (and you only):: + + $ chmod u+x ~/myscripts/mydate + $ chmod go-x ~/myscripts/mydate + +#. Run the file ``mydate`` (it should print the current date & time). Make sure you can run it from any directory (change to your homedirectory and just type ``mydate``).:: + + $ mydate + + Congratulation, you've just created and run your first shell script! + + Bioinformatics -------------- -- GitLab