mirror of https://github.com/01-edu/public.git
feat(left): add subject, test and solution for the exercise
This commit is contained in:
parent
594a8329d6
commit
8995643d53
|
@ -0,0 +1,21 @@
|
|||
10 random facts
|
||||
|
||||
- Avocados are a fruit, not a vegetable. They're technically considered a single-seeded berry, believe it or not.
|
||||
|
||||
- The Eiffel Tower can be 15 cm taller during the summer, due to thermal expansion meaning the iron heats up, the particles gain kinetic energy and take up more space.
|
||||
|
||||
- Trypophobia is the fear of closely-packed holes. Or more specifically, "an aversion to the sight of irregular patterns or clusters of small holes or bumps." No crumpets for them, then.
|
||||
|
||||
- Australia is wider than the moon. The moon sits at 3400km in diameter, while Australia’s diameter from east to west is almost 4000km.
|
||||
|
||||
- 'Mellifluous' is a sound that is pleasingly smooth and musical to hear.
|
||||
|
||||
- The Spice Girls were originally a band called Touch. "When we first started [with the name Touch], we were pretty bland," Mel C told The Guardian in 2018. "We felt like we had to fit into a mould."
|
||||
|
||||
- Human teeth are the only part of the body that cannot heal themselves. Teeth are coated in enamel which is not a living tissue.
|
||||
|
||||
- It's illegal to own just one guinea pig in Switzerland. It's considered animal abuse because they're social beings and get lonely.
|
||||
|
||||
- The Ancient Romans used to drop a piece of toast into their wine for good health - hence why we 'raise a toast'.
|
||||
|
||||
- The heart of a shrimp is located in its head. They also have an open circulatory system, which means they have no arteries and their organs float directly in blood.
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Unofficial Bash Strict Mode
|
||||
set -euo pipefail
|
||||
IFS='
|
||||
'
|
||||
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
|
||||
|
||||
FILENAME="../student/left.sh"
|
||||
cd left
|
||||
|
||||
# True if FILE exists and is a regular file
|
||||
if [ -f ${FILENAME} ]; then
|
||||
# FILE exists and it's not empty
|
||||
if [ -s ${FILENAME} ]; then
|
||||
if [[ $(cat $FILENAME | grep echo | wc -l) -ne 0 ]]; then
|
||||
echo "echo is not allowed in this exercise!"
|
||||
exit 1
|
||||
submitted=$(bash $FILENAME)
|
||||
expected=$(bash ../solutions/left.sh)
|
||||
diff <(echo "$submitted") <(echo "$expected")
|
||||
fi
|
||||
else
|
||||
echo "The file exist but is empty"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "File does not exist"
|
||||
exit 1
|
||||
fi
|
|
@ -0,0 +1 @@
|
|||
wc -l <facts
|
|
@ -0,0 +1,29 @@
|
|||
## left
|
||||
|
||||
### Instructions
|
||||
|
||||
Create a file `left.sh` that will pass the content of a file `facts` to a command that will return the number of lines in that file.
|
||||
|
||||
### Usage
|
||||
|
||||
```console
|
||||
$./left.sh
|
||||
21
|
||||
```
|
||||
|
||||
### Hints
|
||||
|
||||
To pass the content of a file to a command in a shell, you can use the "<" operator followed by the name of the file. For example, to pass the content of a file named "input.txt" to the cat command, you can use the following command:
|
||||
|
||||
`cat < input.txt`
|
||||
|
||||
The `wc` command is a utility in Unix-like operating systems that is used to count the number of lines, words, and bytes in a file or group of files. The -l option tells wc to only print the line count for each file.
|
||||
|
||||
For example, if you have a file called "file.txt" and you want to count the number of lines in the file, you can use the following command:
|
||||
|
||||
`wc -l file.txt`
|
||||
|
||||
This will print the line count for "file.txt".
|
||||
|
||||
> You have to use Man or Google to know more about commands flags, in order to solve this exercise!
|
||||
> Google and Man will be your friends!
|
|
@ -0,0 +1,23 @@
|
|||
10 random facts
|
||||
|
||||
- Avocados are a fruit, not a vegetable. They're technically considered a single-seeded berry, believe it or not.
|
||||
|
||||
- The Eiffel Tower can be 15 cm taller during the summer, due to thermal expansion meaning the iron heats up, the particles gain kinetic energy and take up more space.
|
||||
|
||||
- Trypophobia is the fear of closely-packed holes. Or more specifically, "an aversion to the sight of irregular patterns or clusters of small holes or bumps." No crumpets for them, then.
|
||||
|
||||
- Australia is wider than the moon. The moon sits at 3400km in diameter, while Australia’s diameter from east to west is almost 4000km.
|
||||
|
||||
- 'Mellifluous' is a sound that is pleasingly smooth and musical to hear.
|
||||
|
||||
EOF
|
||||
|
||||
- The Spice Girls were originally a band called Touch. "When we first started [with the name Touch], we were pretty bland," Mel C told The Guardian in 2018. "We felt like we had to fit into a mould."
|
||||
|
||||
- Human teeth are the only part of the body that cannot heal themselves. Teeth are coated in enamel which is not a living tissue.
|
||||
|
||||
- It's illegal to own just one guinea pig in Switzerland. It's considered animal abuse because they're social beings and get lonely.
|
||||
|
||||
- The Ancient Romans used to drop a piece of toast into their wine for good health - hence why we 'raise a toast'.
|
||||
|
||||
- The heart of a shrimp is located in its head. They also have an open circulatory system, which means they have no arteries and their organs float directly in blood.
|
Loading…
Reference in New Issue