GNU Coreutils written in Haskell
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Maxim Likhachev 853db480a4 010/104: yes 2 years ago
src 010/104: yes 2 years ago
.gitignore 001/104: basename 2 years ago
COPYING 001/104: basename 2 years ago
CoC.md 001/104: basename 2 years ago
Makefile 001/104: basename 2 years ago
README.md 002/104: dirname 2 years ago

README.md

GNU Coreutils written in Haskell




Description

This repository provides an implementation of GNU Coreutils in the Haskell programming language.

Some peculiarities:

  • If possible, only Haskell modules included in the GHC distribution are used.

  • The command line arguments are not fully implemented. For example, the --help and --version flags are omitted to keep source code as minimal as possible.

The MaiZure's Decoded: GNU Coreutils article series provided invaluable assistance in the work on this project.

License

All sources are distributed under the GPLv3 license.

Building

GHC and the make utility are required for source code building.

To compile all utilities, you need to execute the following command:

$ make

To build a single utility, pass its name to the make command:

$ make basename

The compiled utilities will be placed in the ./bin directory.

GNU Coreutils:

  • coreutils: Multi-call program.

Output of entire files

  • cat: Concatenate and write files.
  • tac: Concatenate and write files in reverse.
  • nl: Number lines and write files.
  • od: Write files in octal or other formats.
  • base32: Transform data into printable data.
  • base64: Transform data into printable data.
  • basenc: Transform data into printable data.

Formatting file contents

  • fmt: Reformat paragraph text.
  • pr: Paginate or columnate files for printing.
  • fold: Wrap input lines to fit in specified width.

Output of parts of files

  • head: Output the first part of files.
  • tail: Output the last part of files.
  • split: Split a file into pieces..
  • csplit: Split a file into context-determined pieces.

Summarizing files

  • wc: Print newline, word, and byte counts.
  • sum: Print checksum and block counts.
  • cksum: Print CRC checksum and byte counts.
  • b2sum: Print or check BLAKE2 digests.
  • md5sum: Print or check MD5 digests.
  • sha1sum: Print or check SHA-1 digests.
  • sha2 utilities: Print or check SHA-2 digests.

Operating on sorted files

  • sort: Sort text files.
  • shuf: Shuffling text.
  • uniq: Uniquify files.
  • comm: Compare two sorted files line by line.
  • ptx: Produce permuted indexes.
  • tsort: Topological sort.

Operating on fields

  • cut: Print selected parts of lines.
  • paste: Merge lines of files.
  • join: Join lines on a common field.

Operating on characters

  • tr: Translate, squeeze, and/or delete characters.
  • expand: Convert tabs to spaces.
  • unexpand: Convert spaces to tabs.

Directory listing

  • ls: List directory contents.
  • dir: Briefly list directory contents.
  • vdir: Verbosely list directory contents.
  • dircolors: Color setup for ls.

Basic operations

  • cp: Copy files and directories.
  • dd: Convert and copy a file.
  • install: Copy files and set attributes.
  • mv: Move (rename) files.
  • rm: Remove files or directories.
  • shred: Remove files more securely.

Special file types

  • link: Make a hard link via the link syscall.
  • ln: Make links between files.
  • mkdir: Make directories.
  • mkfifo: Make FIFOs (named pipes).
  • mknod: Make block or character special files.
  • readlink: Print value of a symlink or canonical file name.
  • rmdir: Remove empty directories.
  • unlink: Remove files via the unlink syscall.

Changing file attributes

  • chown: Change file owner and group.
  • chgrp: Change group ownership.
  • chmod: Change access permissions.
  • touch: Change file timestamps.

Disk usage

  • df: Report file system disk space usage.
  • du: Estimate file space usage.
  • stat: Report file or file system status.
  • sync: Synchronize cached writes to persistent storage.
  • truncate: Shrink or extend the size of a file.

Printing text

  • echo: Print a line of text.
  • printf: Format and print data.
  • yes: Print a string until interrupted.

Conditions

  • false: Do nothing, unsuccessfully.
  • true: Do nothing, successfully.
  • test: Check file types and compare values.
  • expr: Evaluate expressions.

Redirection

  • tee: Redirect output to multiple files or processes.

File name manipulation

  • basename: Strip directory and suffix from a file name.
  • dirname: Strip last file name component.
  • pathchk: Check file name validity and portability.
  • mktemp: Create temporary file or directory.
  • realpath: Print the resolved file name.

Working context

  • pwd: Print working directory.
  • stty: Print or change terminal characteristics.
  • printenv: Print all or some environment variables.
  • tty: Print file name of terminal on standard input.

User information

  • id: Print user identity.
  • logname: Print current login name.
  • whoami: Print effective user ID.
  • groups: Print group names a user is in.
  • users: Print login names of users currently logged in.
  • who: Print who is currently logged in.

System context

  • date: Print or set system date and time.
  • arch: Print machine hardware name.
  • nproc: Print the number of available processors.
  • uname: Print system information.
  • hostname: Print or set system name.
  • hostid: Print numeric host identifier.
  • uptime: Print system uptime and load.

SELinux context

  • chcon: Change SELinux context of file.
  • runcon: Run a command in specified SELinux context.

Modified command invocation

  • chroot: Run a command with a different root directory.
  • env: Run a command in a modified environment.
  • nice: Run a command with modified niceness.
  • nohup: Run a command immune to hangups.
  • stdbuf: Run a command with modified I/O stream buffering.
  • timeout: Run a command with a time limit.

Process control

  • kill: Send a signal to processes.

Delaying

  • sleep: Delay for a specified time.

Numeric operations

  • factor: Print prime factors.
  • numfmt: Reformat numbers.
  • seq: Print numeric sequences.