Menu

dk-sort

Dirk Krause
← Previous ↑ Home → Next

dk-sort — Sort text line by line

Description

The program sorts input text from the specified files (or from standard input if no file is specified) line by line.
There are some differences to traditional sort programs:

  • Different input encodings
    The program can handle different input encodings (i.e. ASCII, UTF-8 for files produced on Linux/Unix systems and UTF-16 for files produced on Windows systems).
    You can use the -i option to specify an expected input encoding. This choice is overwritten if a BOM (byte order marker) is found at start of input data.
     
  • Options for numeric sorting
    You can use the options -n, -u, or -f to sort input by leading signed integer, unsigned integer, or floating point numbers at start of lines.

Examples

Find newest files (last modified)

To find the files last modified:

dk-ls -r -tf -pmtn | dk-sort
Program Option Purpose
dk-ls List files.
-r Recursive listing including all subdirectories.
-tf Restrict output to files (non-directory items).
-pmtn Set print order to:
  • m Modification time
  • t File type
  • n File name
dk-sort Sort text line by line alphabetically.

Find largest files

To find the largest files in a directory:

dk-ls -r -tf -pstn | dk-sort -u
Program Option Purpose
dk-ls List files.
-r Recursive listing including all subdirectories.
-tf Restrict output to files (non-directory items).
-pstn Set print order to:
  • s File size (number of bytes)
  • t File type
  • n File name
dk-sort Sort text line by line.
-u Sort by unsigned number at start of line.

Group files by file type suffix, sort by size

To list all files, group by file type suffix and sort each group by size:

dk-ls -tf -psn | dk-sort -u -t -s 1
Program Option Purpose
dk-ls List files.
-tf Restrict output to files (non-directory items).
-psn Set print order to:
  • s File size (number of bytes)
  • n File name
dk-sort Sort text line by line.
-u Sort by unsigned number at start of line.
-t Sort by file type suffix.
-s 1 To find the file type suffix, skip the first text word in each line (the size).

Find largest subdirectory

To find the largest subdirectory:

dk-ls -r -td -pstn | dk-sort -u
Program Option Purpose
dk-ls List files.
-r Recursive listing including all subdirectories.
-td Restrict output to directories.
-pstn Set print order to:
  • s File size (number of bytes)
  • t File type
  • n File name
dk-sort Sort text line by line.
-u Sort by unsigned number at start of line.

Group files by file type suffix, sort by modification time

To list all files, group by file type suffix and sort each group by modification timestamp:

dk-ls -tf -pmn | dk-sort -t -s 2
Program Option Purpose
dk-ls List files.
-tf Restrict output to files (non-directory items).
-pmn Set print order to:
  • m Modification timestamp
  • n File name
dk-sort Sort text line by line.
-t Sort by file type suffix.
-s 2 To find the file type suffix, skip the first two text words in each line (modification date and modification timestamp).

Manual

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


← Previous ↑ Home → Next

Related

Wiki: Home
Wiki: dk-sort 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.