-
Notifications
You must be signed in to change notification settings - Fork 0
/
os.Linux
62 lines (54 loc) · 854 Bytes
/
os.Linux
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
55
56
57
58
59
60
61
62
# usage: touch_date <unix ts> <file>
touch_date()
{
touch -d @$1 "$2"
}
# usage: last_modified <file>
last_modified()
{
stat -c "%Y" "$1"
}
# usage: format_last_modified <file>
format_last_modified()
{
# must strip nano-second part otherwise git gets very
# confused, and makes up strange timestamps from the past
# (chances are it decides to interpret it as a unix
# timestamp).
stat -c "%y" "$1" | sed -e '
s/^\([0-9]\{4\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\) \([0-9]\{2\}\):\([0-9]\{2\}\):\([0-9]\{2\}\)\.[0-9]* \(.*\)$/\1-\2-\3 \4:\5:\6 \7/'
}
# usage: head_n [count]
head_n()
{
head -n "$1"
}
# usage: sha1 [file]
sha1()
{
if [ $# = 1 ]
then
sha1sum "$1"
else
sha1sum
fi
}
# usage: cp_a <src> <dst>
cp_a()
{
cp -a "$1" "$2"
}
# usage: _tac
_tac()
{
tac
}
_seq()
{
seq "$@"
return $?
}
_stat_size()
{
stat -c %s "$1"
}