back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 03b5f2909a2ae28f41d21d7557df553b2bd70cb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# ls-imitation

C project that reimplements the functionality of the Unix `ls -l` command.  The
program parses command-line arguments, retrieves file information, and formats
the output similar to GNU `ls`.

<img src="ls.png" />

## Features

- Implements `ls -l` style output:
    - File type and permissions
    - Number of links
    - Owner and group
    - File size
    - Modification time
    - Filename
- Handles both files and directories from command-line arguments
- Prints directory headers and separators when multiple directories are listed
- Detects whether output is a terminal (`isatty`) and adjusts formatting
- Maintains a linked-list of file entries with conversion to arrays
- Supports sorting file entries by filename
- Column alignment for neat tabular output
- Edge cases handled (empty input, single file, multiple directories, etc.)
- Simple build system via `Makefile`

## Building

### On Linux

```bash
git clone https://git.scratko.xyz/ls-imitation
cd ls-imitation
make
./ls-imitation
```

## Usage

The program mimics the behavior of `ls -l`.  Instead of calling `ls -l`, run:

```bash
./ls-imitation <files or directories>
```
### Examples

```bash
./ls-imitation
./ls-imitation file.txt
./ls-imitation dir1 dir2
./ls-imitation file1.txt dir/
```