This commit is contained in:
Antranig Vartanian
2023-03-14 16:34:51 +04:00
commit a2d0d3f216
7 changed files with 133 additions and 0 deletions

23
Git.md Normal file
View File

@ -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 :)

12
README.md Normal file
View File

@ -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)

17
Shell.md Normal file
View File

@ -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
```

21
Unix.md Normal file
View File

@ -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` :)

18
answers/Unix.md Normal file
View File

@ -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 -`

23
hints/Shell.md Normal file
View File

@ -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 :)

19
hints/Unix.md Normal file
View File

@ -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"