File: os.Darwin

package info (click to toggle)
guilt 0.36-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,312 kB
  • sloc: sh: 3,063; makefile: 95; perl: 42
file content (70 lines) | stat: -rw-r--r-- 1,002 bytes parent folder | download | duplicates (3)
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
63
64
65
66
67
68
69
70
# usage: touch_date <unix ts> <file>
touch_date()
{
	touch -t `date -r $1 +%Y%m%d%H%M.%S` "$2"
}

# usage: last_modified <file>
last_modified()
{
	stat -f "%m" "$1"
}

# usage: format_last_modified <file>
format_last_modified()
{
	stat -f "%Sm" -t "%Y-%m-%d %H:%M:%S %z" "$1"
}

# usage: head_n [count]
head_n()
{
	if [ "$1" -gt 0 ]; then
		head -n "$1"
	fi
}

# usage: sha1 [file]
sha1()
{
	if [ $# = 1 ]
	then
		openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
	else
		openssl dgst -sha1 | sed 's,\(.*= \)*\(.*\),\2  -,'
	fi
}

# usage: cp_a <src> <dst>
cp_a()
{
	cp -pR "$1" "$2"
}

# usage: _tac
_tac()
{
	sed -e '1!G;h;$!d'
}

_seq()
{
	(
		if [ $# -eq 1 ]
		then
			/usr/bin/jot $1
		elif [ $# -eq 2 ]
		then
			n1=$((${2} - ${1} + 1))
			n2=$1
			/usr/bin/jot $n1 $n2
		elif [ $# -eq 3 ]
		then
			num1=$1
			incr=$2
			num2=$3
			/usr/bin/awk -v n1=$num1 -v n2=$num2 -v add=$incr 'BEGIN{ for(i=n1; i<=n2; i+=add) print i;}' | /usr/bin/sed -E '/e/s/^.+e.+$/0/'
		fi
	)
	return 0
}