Menu

dk-lines

Dirk Krause
← Previous ↑ Home → Next

dk-lines — Select text lines

Description

The program extracts specified lines from a text obtained from the specified files or standard input. It is mainly intended for the Windows platforms, as I do not know about an UTF-16 aware version of "head" or "tail" programs for Windows.

There are 2 processing stages, both stages are optional.

Stage 1: Text at beginning of line.
In the first stage the beginning of each text line is compared against a start text and/or an end text. Lines from within the range (including the borders) are transferred to stage 2. If only start or end text is specified, a simple comparison is used instead of the range check.

Stage 2: Line numbers.
The second stage selects lines from stage 1 output by line numbers. A start line number and/or an end line number can be specified. Positive line numbers are counted from the first line (line number 1) forwards. Negative line numbers are counted from the final line (line number -1) backwards.


Examples

Find files modified in a specified range of dates

To find files modified in a specified range of dates:

dk-ls -pmn -tf -r | dk-lines --from=2017-11-18 --to=2017-11-19
Program Option Purpose
dk-ls List files.
-pmn Configure output columns:
  • m Modification timestamp
  • n File name
-tf Restrict output to files (non-directory items).
-r Recursive listing including all subdirectories.
dk-lines Extract specific lines from text stream.
--from=2017-11-18
--to=2017-11-19
Only those lines beginning with text from (inclusive) "2017-11-18" to (inclusive) "2017-11-19".

Find files modified today

To find files modified today:

dk-ls -pmn -tf -r | dk-lines --today
Option Purpose
--today Extract only thos lines beginning with yyyy-mm-dd (current date).

Find 10 newest files (last modified)

To find 10 newest files (last modified):

dk-ls -pmn -tf -r | dk-sort | dk-lines -l -10
Option Purpose
-l -10 Begin extraction at line 10 before the end.

Find 10 oldest files (by modification date)

To find 10 oldest files (by modification date):

dk-ls -pmn -tf -r | dk-sort | dk-lines -l 1/10
Option Purpose
-l 1/10 Extract line number 1 to 10.

Show file contents, omit first 3 and final 2 lines

To show file x.txt contents, omit first 3 and final 2 lines:

dk-lines -l 4/-3 x.txt
Option Purpose
-l 4/-3 Start at line 4 from the beginning, stop at line 3 before the end.

Manual

See the [dk-lines manual] for the full documentation of the program.


← Previous ↑ Home → Next

Related

Wiki: Home
Wiki: dk-lines manual

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.