mirror of https://github.com/01-edu/public.git
feat(skip-lines): add subject, test and solution for the exercise skip-line
This commit is contained in:
parent
5d6875d0a8
commit
4b02c825b7
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Unofficial Bash Strict Mode
|
||||
set -euo pipefail
|
||||
IFS='
|
||||
'
|
||||
|
||||
submitted=$(bash student/skip-lines.sh)
|
||||
expected=$(bash solutions/skip-lines.sh)
|
||||
|
||||
diff <(echo "$submitted") <(echo "$expected")
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ls -l | sed -n 'n;p'
|
|
@ -0,0 +1,47 @@
|
|||
## Skip lines
|
||||
|
||||
### Instructions
|
||||
|
||||
Write a command line in a `skip-lines.sh` file that prints the result of a `ls -l` skipping 1 line out of 2, starting with the **first** one.
|
||||
|
||||
Example:
|
||||
|
||||
```console
|
||||
User-> ls -l
|
||||
drwxr-xr-x 16 User User 4096 nov 11 10:55 Desktop
|
||||
drwxr-xr-x 22 User User 4096 nov 4 10:02 Documents
|
||||
drwxr-xr-x 6 User User 4096 nov 11 10:40 Downloads
|
||||
drwxr-xr-x 2 User User 4096 mar 31 2022 Music
|
||||
drwxr-xr-x 2 User User 4096 set 29 10:34 Pictures
|
||||
drwxr-xr-x 2 User User 4096 nov 23 2021 Public
|
||||
```
|
||||
|
||||
What we want your script to do is:
|
||||
|
||||
```console
|
||||
drwxr-xr-x 16 User User 4096 nov 11 10:55 Desktop
|
||||
drwxr-xr-x 6 User User 4096 nov 11 10:40 Downloads
|
||||
drwxr-xr-x 2 User User 4096 set 29 10:34 Pictures
|
||||
```
|
||||
|
||||
**Tips:**
|
||||
|
||||
Here are some Commands that can help you:
|
||||
|
||||
- `sed`. Edit text in a scriptable manner. You can see also: awk. [For more information](https://www.gnu.org/software/sed/manual/sed.html).
|
||||
|
||||
- Print just a first line to stdout:
|
||||
`{{command}} | sed -n '1p'`
|
||||
|
||||
```console
|
||||
User-> cat file
|
||||
AIX
|
||||
Solaris
|
||||
Unix
|
||||
Linux
|
||||
HPUX
|
||||
User-> sed -n '1p' file
|
||||
AIX
|
||||
```
|
||||
|
||||
Use man to see how `awk` or `sed` works, they can do the job.
|
Loading…
Reference in New Issue