Crates.io | skip |
lib.rs | skip |
version | 0.2.1 |
source | src |
created_at | 2018-11-30 08:00:37.313819 |
updated_at | 2024-02-28 17:22:06.036374 |
description | Skip lines in a file |
homepage | |
repository | https://git.kemitix.net/kemitix/skip |
max_upload_size | |
id | 99349 |
size | 23,857 |
Skip part of a file.
As head
will show the top of a file after a number of line,
so skip
will do the opposite, and not show the top of the file,
but will show the rest.
Additionally, it can check for whole lines matching, or for a token being present on the line.
N.B.: The skip
crate used to be an implementation of Skip list,
by Luo Jia / Zhouqi Jiang (source).
That crate will be republished as skip-list (soon).
This example reads the file from stdin.
echo "line 1
line 2
line 3
line 4" > input.txt
skip 2 < input.txt
Will output:
line 3
line 4
The whole line must match.
This example reads the named file.
echo "alpha
beta
alpha
alpha
gamma
alpha" > input.txt
skip 2 --line alpha input.txt
Will output:
alpha
gamma
alpha
Looks for a string within a line, counting each occurance.
This example reads the file from stdin.
echo "Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.
Ut enim ad minim veniam,
quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea
commodo consequat." > input.txt
cat input.txt | skip 2 --token dolor
Will output:
Ut enim ad minim veniam,
quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea
commodo consequat.
It matches the first dolor
on line 1,
and the second on line 4 as part of the word dolore
.
Looks for a string within a line, only counting each matching line once.
This example reads the file from stdin.
echo "Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.
Ut enim ad minim veniam,
quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea
commodo consequat." > input.txt
cat input.txt | skip 4 --token m --ignore-extras
Will output:
quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea
commodo consequat.
Without --ignore-extras
, it would have found the fourth m
on line 3.
echo "Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.
Ut enim ad minim veniam,
quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea
commodo consequat." > input.txt
cat input.txt | skip 4 --token m
Outputing:
ut labore et dolore magna aliqua.
Ut enim ad minim veniam,
quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea
commodo consequat.