-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathls.txt
55 lines (48 loc) · 1.72 KB
/
ls.txt
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
53
54
ls
-l # list/long format
-a # include dot-files
-A # include dot-files but not the current and parent directory
-h # human-readable filesizes
-S # order by size (-s shows "allocated size in blocks")
-t # order by time
-r # reverse order
-i # show inode number
-Z # print security context (AppArmor, SELinux, ..)
# get time with seconds and sub-seconds if the OS/FS supports it
$ ls --full-time
# which is shorthand for
$ ls -l --time-style=full-iso
From https://stackoverflow.com/a/24812068/126584
In the list format, the first character, before the permissions, indicates the type of 'file':
- regular file
d directory
l symbolic link
b block special file/block device: tends to be storage devices, buffers output, writes per block
c character special file/character device: tends to be audio/graphics cards, keyboard, mouse
C high performance ("contiguous data") file
D door (Solaris 2.5 and up)
M off-line ("migrated") file (Cray DMF)
n network special file (HP-UX)
p FIFO (named pipe)
P port (Solaris 10 and up)
s socketqq
# If there's a \e[38;5;201m+\e[0m sign trailing the permissions, that file/directory has extended permissions called ACLs for Access
# Control List. use \e[38;5;208mgetfacl <file>\e[0m or \e[38;5;208mls -le [file]\e[0m to view them, depending on OS.
See also: \e[38;5;208mstat\e[0m
==
# show last 10 (or given number of) modified files
# not bugfree wrt dotfiles and/or piping, not sure
lt ()
{
local lines=10;
local rf='^[0-9]+$';
if [[ "$1" =~ $rf ]]; then
lines=$1;
shift;
fi;
if [[ -t 1 ]]; then
command ls --color=always -lAt "$@" | head -n$((lines+1)) | tail -n$lines;
else
command ls -At "$@" | head -n$lines;
fi
}