Exercises
1 Shell
Exercise
The following code is written in bash and creates folders named folder1, folder2,…,folder10:
Note the close similarity with Python.
Create a new file named create_folders.sh using the command touch. Edit the file directly in the shell using either the command nano (easier) or vim (harder) and type the script inside the file.
Then, run the script via
Complete the following tasks by solely using the shell:
- Rename
folder10asfolder0 - Delete folder
folder0 - Create a file inside
folder1calledREADME.mdand type the following text:
This is a README.md file
It contains essential documentation on the project.
- Change the working directory name to
folder1 - Use the command
grepto print out at what line the wordessentialis contained in the fileREADME.md
2 Git+Shell
Exercises
Assuming that you have completed the main tasks of this workshop, complete the following additional tasks on your git repository:
- Using
git --helpto find a way to consult the log of your various commits - The shell has an operator called output redirection: it is the symbol
>. Use output redirection to write your log to a file namedmygit.log - Add the
mygit.logfile to the repository on themainbranch and commit the changes. - Check the new status of the
log: can you find your commit? - We now want to go back to a version of the commit prior to the addition fo the log file. Every commit has its own unique id (strings like
455005dc29dc6727de7ee36fee4b49a13b39f73f) called commit hashes. Find the commit hash of the commit that precedes our latest addition. To reset the master to that point use
git reset --hard <commit-hash>
Is the mygit.log still there?