mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
53 lines
1.2 KiB
2 years ago
|
## 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
|
||
2 years ago
|
$ ls -l
|
||
2 years ago
|
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
|
||
|
```
|
||
|
|
||
2 years ago
|
### Hints
|
||
2 years ago
|
|
||
|
Here are some Commands that can help you:
|
||
|
|
||
2 years ago
|
- `sed`. Edit text in a scriptable manner.
|
||
2 years ago
|
|
||
|
- Print just a first line to stdout:
|
||
|
`{{command}} | sed -n '1p'`
|
||
|
|
||
|
```console
|
||
2 years ago
|
$ cat file
|
||
2 years ago
|
AIX
|
||
|
Solaris
|
||
|
Unix
|
||
|
Linux
|
||
|
HPUX
|
||
2 years ago
|
$ sed -n '1p' file
|
||
2 years ago
|
AIX
|
||
|
```
|
||
|
|
||
2 years ago
|
> 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!
|
||
|
|
||
|
### References
|
||
|
|
||
|
- [Sed](https://www.gnu.org/software/sed/manual/sed.html).
|