# Lab 3. Shell scripting and Systemd
## *Kseniya Evdokimova*
---
## **Questions to answer:**
#### 1. Create a simple script to print odd numbers from 1 to 10.
- Lets create a script
`$vim myfunction`
- Inside vim type the following

- We need to make this script executable
`$chmod 700 myfunction`
- To run the script execute:
`./myfunction`

Or one more solution:

#### 2. Create a shell script which makes new users and their corresponding passwords for 10 accounts in the system. Script should read the data from the file users.txt(you can write data to this file).
- Create users.txt
`nano users.txt`

- Create the script for 10 users
`nano userscreator`

- We need to make this script executable
`$chmod 700 userscreator`

- To run the script execute:
`./userscreator`

And as the output we will get:

#### 3. Provide an example of the shell script where you can pass result (not an exit code) of the executed function in a subshell to the parent’s shell
The whole point of a subshell is that it doesn't affect the calling session. In bash a subshell is a child process, other shells differ but even then a variable setting in a subshell does not affect the caller. So the subshell should't have access to its parent's environment (within the abstraction that Bash can provide).
One alternative is for the subshell to write assignment statements to a temporary file for its parent to read:
`a=3`
`(echo 'a=4' > tmp)`
`. tmp`
`rm tmp`
`echo "$a"`
#### 4. Create script that redirects system date and disk utilization in a file with systemd.