lsfrom: List directory files starting from a specific name

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Warnings:

lsfrom lists the entries of a directory starting from a particular file in locale collation order, which can be useful for continuing a shell command or script after a failure on an entry.


[Skip to Readme]

Properties

Versions 0.1, 0.1.1, 0.1.1.1, 1.0, 2.0, 2.0
Change log ChangeLog.md
Dependencies base (<5), directory, extra, filepath, setlocale, simple-cmd (>=0.2.0), simple-cmd-args (>=0.1.8) [details]
License BSD-3-Clause
Copyright 2018,2021-2025 Jens Petersen
Author Jens Petersen <petersen@redhat.com>
Maintainer Jens Petersen <petersen@redhat.com>
Category Utility
Home page https://github.com/juhp/lsfrom
Bug tracker https://github.com/juhp/lsfrom/issues
Source repo head: git clone https://github.com/juhp/lsfrom.git
Uploaded by JensPetersen at 2025-02-10T16:20:35Z

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for lsfrom-2.0

[back to package description]

lsfrom

lsfrom lists the files and/or dirs in a directory starting from the given filename or the next one after that, using the current locale collation order.

Tutorial

Consider a directory with a few files:

$ ls
A b B C

(lsfrom is typically more useful in larger directories, but to keep things simple let's use a small example here.)

Let's list the files after b:

$ lsfrom --after b/
B
C

Equivalently the files from B:

$ echo $(lsfrom --from B)
B C

We can also list until:

$ lsfrom --until B
A
b
B

Note the file (collation) order will depend on the locale in general:

$ LC_COLLATE=C echo $(lsfrom -f B)
B C b

--from/--after can be combined with --until/--before. Without any of these options, the output should be similar to ls -A, but only 1 file per line.

The file of the path given does not need to exist (unless using --strict mode):

$ lsfrom -a /t
/tmp
/usr
/var

It is also possible to filter the listing with --dirs or --files.

A common use-case is continuing a program or script on the entries of a directory after a failure, etc:

$ myscript.sh $(lsfrom -f next)

or only running a command on a subrange of files or dirs in a directory.

Usage

$ lsfrom --version

2.0

$ lsfrom -h

List directories files starting from file

Usage: lsfrom [--version] [-s|--strict] [-A|--all] [--dirs | --files]
              [(-f|--from STARTFILE) | (-a|--after STARTFILE)]
              [(-u|--until LASTFILE) | (-b|--before LASTFILE)]

  lsfrom lists the files in a directory that follow from the given file

Available options:
  -h,--help                Show this help text
  --version                Show version
  -s,--strict              fail if specified file(s) do not exist
  -A,--all                 include hidden (dot) files
  --dirs                   Only list directories
  --files                  Only list files
  -f,--from STARTFILE      files from STARTFILE
  -a,--after STARTFILE     files after STARTFILE
  -u,--until LASTFILE      files until LASTFILE
  -b,--before LASTFILE     files before LASTFILE

Requirements

Tested on Linux (may also work on MacOS): specifically it uses libc collation (wcscoll()) for file ordering.

It also uses ls to list files sorted in the locale collation with the -A option to exclude ./ and ../ (ie coreutils).

Installation

stack install lsfrom or cabal install lsfrom.

Contribute or feedback

lsfrom is distributed with BSD license and the project is hosted at https://github.com/juhp/lsfrom.