No description
Find a file
2022-01-15 14:44:21 +00:00
.github/workflows github build with 0.9.0 and master 2022-01-01 16:05:57 +00:00
src Ignore extras by only counting line with a token 2022-01-15 14:39:08 +00:00
.gitattributes Add zigmod and zig-clap 2021-12-30 08:03:46 +00:00
.gitignore ignore dist dir 2022-01-15 14:38:56 +00:00
build.zig Add zigmod and zig-clap 2021-12-30 08:03:46 +00:00
LICENSE Initial commit 2021-12-29 18:26:42 +00:00
Makefile Add Makefile 2022-01-15 14:29:51 +00:00
README.md README: add notes in --ignore-extras 2022-01-15 14:44:21 +00:00
test.sh colourise diff output 2022-01-15 14:38:26 +00:00
zig.mod Add zigmod and zig-clap 2021-12-30 08:03:46 +00:00
zigmod.lock Add zigmod and zig-clap 2021-12-30 08:03:46 +00:00

skip

Skip part of a file.

GitHub release (latest by date) GitHub Release Date

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.

Usage

Skip a fixed number of lines

This example reads the file from stdin.

File: input.txt

line 1
line 2
line 3
line 4
skip 2 < input.txt

Will output:

line 3
line 4

Skip until a number of matching lines

The whole line must match.

This example reads the named file.

File: input.txt

alpha
beta
alpha
alpha
gamma
alpha
skip 2 --line alpha input.txt

Will output:

alpha
gamma
alpha

Skip lines until a number of tokens are seen

Looks for a string within a line, counting each occurance.

This example reads the file from stdin.

File: input.txt

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. 
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.

Skip lines until a lines with tokens are seen

Looks for a string within a line, only counting each matching line once.

This example reads the file from stdin.

File: input.txt

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. 
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, and displayed:

ut labore et dolore magna aliqua. 
Ut enim ad minim veniam, 
quis nostrud exercitation ullamco 
laboris nisi ut aliquip ex ea 
commodo consequat.