From a2d0d3f2167f8bdebd76e8ca69d1287ff0296af4 Mon Sep 17 00:00:00 2001 From: Antranig Vartanian Date: Tue, 14 Mar 2023 16:34:51 +0400 Subject: [PATCH] init --- Git.md | 23 +++++++++++++++++++++++ README.md | 12 ++++++++++++ Shell.md | 17 +++++++++++++++++ Unix.md | 21 +++++++++++++++++++++ answers/Unix.md | 18 ++++++++++++++++++ hints/Shell.md | 23 +++++++++++++++++++++++ hints/Unix.md | 19 +++++++++++++++++++ 7 files changed, 133 insertions(+) create mode 100644 Git.md create mode 100644 README.md create mode 100644 Shell.md create mode 100644 Unix.md create mode 100644 answers/Unix.md create mode 100644 hints/Shell.md create mode 100644 hints/Unix.md diff --git a/Git.md b/Git.md new file mode 100644 index 0000000..1ea13a9 --- /dev/null +++ b/Git.md @@ -0,0 +1,23 @@ +# Git + +Git exercises that will help you, always! + +> Use the git, Luke! +> +> -- Obi-Wan Kenobi, to Luke the Programmer + +## Getting Started + +1. Create a git repository, locally +2. Add some files to it, maybe copy `empty` here? :) +3. Commit `empty` to the source tree +4. Make a remote repository on `git.belltower.it` +5. Push all your local content to the remote! + +## Forking + +1. Fork bellhotel from [`antranig/bellhotel`](https://git.belltower.it/antranig/bellhotel) +2. Make some modifications. +3. Make a Pull Request! +4. Wait for a response :) + diff --git a/README.md b/README.md new file mode 100644 index 0000000..7405b81 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# Workouts! + +This repository contains exercises for anyone who wants to improve their knowledge around systems. + +This is a *live* repository, so there will be changes :) + +Here's the roadmap! + +1. [Unix.md](Unix.md) +2. [Shell.md](Shell.md) +3. [Git.md](Git.md) + diff --git a/Shell.md b/Shell.md new file mode 100644 index 0000000..5c1cf76 --- /dev/null +++ b/Shell.md @@ -0,0 +1,17 @@ +# Unix Shell + +These exercises are meant for people who want to improve their Shell Programming knowledge + +## Whitespace Renamer + +Write a program that gets a directory as an input via arguments and renames all files which have spaces in their name to `_`, so `Contract 4242 for BellTech.pdf` becomes `Contract_4242_for_BellTech.pdf`. + +## Expected Result + +``` +$ sh find_and_replace.sh +Usage: find_and_replace.sh [-v] path +$ sh find_and_replace.sh -v /path/to/directory +Renaming 'My Document.txt' -> My_Document.txt +``` + diff --git a/Unix.md b/Unix.md new file mode 100644 index 0000000..6830001 --- /dev/null +++ b/Unix.md @@ -0,0 +1,21 @@ +# Unix Workout + +The exercises in this document is meant to improve your Unix knowledge, such as daily commands and manual pages. + +## Single commands + +1. Find all text files (`.txt`) in your home directory using the `find` command +2. Create an empty file named `empty` +3. List the `empty` file with its permissions. +4. Who are you in this system? what is your username? what is your user ID? which groups do you belong to? +5. What's the date and time right now? + +## Piping commands together + +1. Did you find all the `.txt` files? good! now put that output into `/tmp/txtfiles` +2. Without using a text editor, put `hello there!` into `empty` +3. Using your favorite editor, Vim, put more content into `empty` +4. Print the content. +5. Print the content and look if the string `lo` is in there! + 1. Which line is it on? +6. Get the date, again, and *pipe* it into `vim` :) \ No newline at end of file diff --git a/answers/Unix.md b/answers/Unix.md new file mode 100644 index 0000000..5d5cea0 --- /dev/null +++ b/answers/Unix.md @@ -0,0 +1,18 @@ +# Unix Answers + +## Single commands + +1. `find . -name '*.txt'` +2. `touch empty` +3. `ls -l empty` +4. `id` +5. `date` + +## Piping commands together + +1. `find . -name '*.txt' > /tmp/txtfiles` +2. `echo 'hello there!' >> empty` +3. `vim empty` +4. `cat empty` +5. `grep -n lo empty` +6. `date | vim -` \ No newline at end of file diff --git a/hints/Shell.md b/hints/Shell.md new file mode 100644 index 0000000..dea4e6f --- /dev/null +++ b/hints/Shell.md @@ -0,0 +1,23 @@ +# Unix Shell + +## Manuals you'd need + +### Testing + +If you want to test a string, value or a path, you can use `[` + +E.g. + +`[ 1 = 1 ]` will return 0, which means true + +### Getting Values from CLI + +Usually, `$#` means number of arguments, while `$1`, `$2` ... returns the argument. + +Special cases: + +1. `$@` returns all arguments +2. `$0` returns the program itself + +> Pro tip: there are multiple ways to do this :) + diff --git a/hints/Unix.md b/hints/Unix.md new file mode 100644 index 0000000..040fefc --- /dev/null +++ b/hints/Unix.md @@ -0,0 +1,19 @@ +# Hints for Unix + +## Single commands + +1. `man find` should tell you everything you need +2. `touch` is an interesting command :) +3. checkout `man ls` for more info +4. start with `man whoami` +5. `time` and `date` are very weird. `time` doesn't display the current time, but rather a command's time. `date` on the other hand. + +## Piping commands together + +1. You may Google "Shell Redirection" +2. Again, it's shell redirections! +3. If lost, open `vimtutor` +4. A cat is not just a cute pet. +5. **G**et that **R**egular **E**xpression and **P**rint + 1. Manual pages are friendly! +6. You may Google "unix standard input"