sl : a mirror version of ls

Ever heard of the Steam Locomotive? It is supposed to cure your bad habit of mistyping [ ls ] by running an ASCII rendition of a steam locomotive through your terminal.

I didn't like it and made another program of the same name. My sl just mirrors the output of ls . It accepts most ls (1) arguments and is best enjoyed with -l .

source code #!/bin/bash # sl - prints a mirror image of ls. (C) 2017 Tobias Girstmair, https://gir.st/, GPLv3 LEN=$(ls "$@" |wc -L) # get the length of the longest line ls "$@" | rev | while read -r line do printf "%${LEN}.${LEN}s\

" "$line" | sed 's/^\(\s\+\)\(\S\+\)/\2\1/' done

Here's an example:

13:37 t@hostname: /tmp/jpvtx-0.2.1 % sl -l [0] 67 latot 2 60:40 91 raM 02893 t t 2 .x-rx-rxwrd tuo.a 55:51 91 raM 6738 t t 1 .x-rx-rxwr- SEGNAHC 5002 22 yaM 603 t t 1 .--r--r-wr- c.xtvpj 5002 22 yaM 7909 t t 1 .--r--r-wr- ESNECIL 5002 22 yaM 67971 t t 1 .--r--r-wr- elifekaM 5002 22 yaM 131 t t 1 .--r--r-wr- EMDAER 5002 22 yaM 795 t t 1 .--r--r-wr- h.selbat 5002 22 yaM 0153 t t 1 .--r--r-wr- c.xtv 35:51 91 raM 3507 t t 1 .--r--r-wr- c.iicsa_ot_xtv 41:61 91 raM 6265 t t 1 .--r--r-wr-

13:37 t@hostname: /tmp/jpvtx-0.2.1 % ls -l [0] total 76 drwxr-xr-x. 2 t t 39820 Mar 19 04:06 2 -rwxr-xr-x. 1 t t 8376 Mar 19 15:55 a.out -rw-r--r--. 1 t t 306 May 22 2005 CHANGES -rw-r--r--. 1 t t 9097 May 22 2005 jpvtx.c -rw-r--r--. 1 t t 17976 May 22 2005 LICENSE -rw-r--r--. 1 t t 131 May 22 2005 Makefile -rw-r--r--. 1 t t 597 May 22 2005 README -rw-r--r--. 1 t t 3510 May 22 2005 tables.h -rw-r--r--. 1 t t 7053 Mar 19 15:53 vtx.c -rw-r--r--. 1 t t 5626 Mar 19 16:14 vtx_to_ascii.c 13:37 t@hostname: /tmp/jpvtx-0.2.1 % [0]

Consider this code GPLv3 licensed.