lsfrom
List directory files starting from a specific name
https://github.com/juhp/lsfrom
Stackage Nightly 2025-05-15: | 2.0 |
Latest on Hackage: | 2.0 |
lsfrom-2.0@sha256:f60f13810ec5cb9eed89c5a00dcf00abae5dd5088496c0af44596012c1c80515,2360
Module documentation for 2.0
There are no documented modules for this package.
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.
Changes
Release history for lsfrom
2.0 (2025-02-10)
- major rewrite introducing –from file option
- –after, –until, –before are also file options
- uses locale collation with C FFI
- add –dirs and –files file-type filters
1.0 (2024-01-07)
- add –after: start with the next file after the specified one
- add –until: include files only up to the specified file
- add –before: changes the behaviour of –until
- add –strict: error if the specified files do not exist
- the short option for –all is now -A
0.1.1.1 (2022-04-24)
- add missing test files
- fix testsuite for lts 12 and earlier
0.1.1 (2022-04-24)
- use
ls -A
- improve documentation
0.1 (2021-02-06)
- initial Hackage release
- supports filepaths now not just file pattern
- uses system locale collation