Menu

dk-ls manual

Dirk Krause
← Previous ↑ Home → Next

dk-ls — List files, configurable column order

Synopsis

dk-ls [_options_] [_files_]

Description

The dk-ls program shows information about files and directories. There are some differences to traditional "ls" or "dir" programs:

  • Configurable output column order
    The output column order is configurable. To search for newest files, print modification time first and use a "sort" program. To search for largest files, print size first and use a numeric sort…
     
  • Directory size calculation
    The size shown for a directory is the summary of the directory size and the contents size.
     
  • Use of UTF-16 encoding for output on Windows
    On Windows the program produces UTF-16 encoded output, so it can show non-English text in file names properly.

Options

Option Purpose
-p string
--print-order=string
Specify print order, see table below.
The default is "mtpn" on non-Windows systems, "mtn" on Windows.
-r
--recursive
Recursive listing.
-f
--stay-on-filesystem
Stay on current file system for recursive listings.
-s
--summary
Show summary at end (number of reported directories and files and total size in bytes).
-t string
--types=string
Restrict output to directories (character "d") or files and other non-directory items (character "f"). Default is to show both.
-m string
‑‑message‑digest=string
Message digest type and encoding, see table below. The default is "md5.hex".
-R
--reset
Reset, ignore preference settings for print order and message digest type.

Each character in the print order string represents an output column.

Character Information
n File name
For symbolic links the target file name is shown if the "n" character is the final character in the print order string.
N File name
For symbolic links the target file name is not shown.
s File size.
t File type.
p File permissions (attributes on Windows systems).
u User ID of file owner (not on Windows systems).
g Group ID owning the file (not on Windows systems).
c Creation timestamp.
m Modification timestamp.
a Last access timestamp.
l Number of links (not on Windows systems).
d Device number (volume serial number on Windows systems).
r Relative device number (volume serial number on Windows systems).
i Inode number (file index on Windows systems).
w Windows reparse point tag value (only on Windows systems).
x Message digest (checksum).

Output columns are separated by a space, except "di" by a colon and "tp" not separated, as "di" together form the unique file identifier and printing type and permission without space is the default in the "ls" program.

Message digest type and encoding

Message digest type and encoding. Digest type and encoding are separated by dot. The message digest type is one from:

  • md5
  • sha-1
  • sha-224
  • sha-256
  • sha-384
  • sha-512
  • ripemd-160

The encoding is one from:

  • hex (ASCII-Hex encoding)
  • a85 (ASCII-85 encoding)

The default is "md5.hex".


Output

File type and permissions output on non-Windows systems

File type

File type output consists of two characters:

  • a link indicator and
  • a type indicator.
Link indicator Type of link
- Not a symbolic link.
l Symbolic link, target is in same file system as link.
L Symbolic link, target is in different file system.
! Dangling link, target does not exist.
Type indicator File type
- Regular file.
d Directory.
p Pipe (FIFO).
c Character special device.
b Block special device.
s Socket.
C Multiplexed character special device.
B Multiplexed block special device.
D Name service door.
e Event port.
o Xenix special file.
n Xenix semaphore.
m Xenix shared data.
v VXFS compressed file.
n Network special file.
w Whiteout.
a ACL shadow entry.

Permissions

Short summary: Permissions are shown in the same notation as "ls -l" does.

The output consists of 3 groups:

  • file owner permissions,
  • file group permissions,
  • other users permissions.

Each group consists of 3 characters:

Character number Character Permission
1 r Read permission granted.
- No read permission granted.
2 w Write permission granted.
- Write permission not granted.
3 x Execute permission granted.
- Execute permission not granted.

If the set user ID bit is set, the execution permission character for the user is changed from "x" to "s" or from "-" to "S".

If the set group ID bit is set, the execution permission character for the group is changed from "x" to "s" or from "-" to "S".

If the restricted deletion flag or sticky bit is set, the execution permission character for others is changed from "x" to "t" or from "-" to "T".

File type and attributes output on Windows systems

File type

The file type on Windows consists of a reparse point character and a file type character.

Reparse point character Indicates
- File is not a reparse point.
m Mount point.
l Symbolic link.
w Mounted WIM image.
s SIS reparse point.
n NFS reparse point.
c CSV reparse point.
d DFS reparse point.
f DFSR reparse point.
u Deduplication reparse point.
h HSM reparse point.
2 HSM2 reparse point.
File type character Indicates
- Regular file.
d Directory.
b Block device

Attributes

Attributes are written as group of characters.

Position Character Indicates
1 R Read only.
- Not read only.
2 S System file.
- Not a system file.
3 H Hidden.
- Not hidden.
4 I Indexed.
- Not indexed.
5 C Compressed.
- Not compressed.
6 E Encrypted.
- Not encrypted.
7 O Offline.
- Not offline.
8 P Sparse.
- Not sparse.
9 T Temporary.
- Not temporary.
10 V Virtual.
- Not virtual.

Exit status

0 on success, all other status codes indicate an error.


Diagnostics

A sequence of question marks is printed if the program fails to obtain device number, volume serial number, inode number, or file index number.

A single question mark is printed if the program fails to obtain number of links, file owner UID, or file owner GID.

A sequence of "x" characters is printed if a message digest is requested for anything else than a regular file or if the program failed to read the file.


Configuration

The following preferences can be used to set defaults:

Preference Purpose
print.order Print order if the -p option was not used.
message.digest Message digest type and encoding if the -m option was not used.

Restrictions

On systems supporting hard links the program reports incorrect
directory sizes for directories containing the same file multiple
times as hard links. Each occurance is counted.

Restrictions on Windows systems

Path name length restrictions

On Windows the file name length is restricted to _MAX_PATH (260) characters if the file name contains a wildcard (* or ? character).

Does not print owner or group

On Windows systems user management and file permission concepts differ significantly from the concepts on Linux and Unix systems. The characters "u" and "g" in the print order specification have no effect.

Not all information available for non-administrative users

On Windows systems there are different functions available to obtain information about files. Sometimes a function delivering less information succeeds for files where the default function delivering more information fails (i.e. when non-privileged processes ask for information about c:\pagefile.sys). In such situations we can not print volume serial number, file index or number of links. Question marks are shown instead.

Quoted file names on windows

On Windows systems the backslash is used for two purposes:

  • as separator between path name components and
  • as escape character, i.e. in double quoted strings.

Quotes are used around text containing spaces to pass the entire text as one argument to a command. Unfortunately quoting also activates processing of backslashes as start of escape sequences.

Text typed in
the shell
Text passed as argument
to a command
Better type in
the shell
C: C:  
"C:" C:  
C:\ C:\  
"C:\" C:" "C:\\"
C:\\ C:\\  
"C:\\" C:\  

Restrictions on non-Windows systems

On non-Windows systems there is no reparse point tag, so a "w" in the print order specification has no effect.


Notes

This program uses DK libraries version 4.


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

← Previous ↑ Home → Next

Related

Wiki: dk-ls