-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions
63 lines (53 loc) · 1.05 KB
/
functions
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
#
# Defines functions.
#
# Authors:
# Julen Pardo <julen.pardo@outlook.es>
#
#
# Crypto
#
function sha1() {
if [[ -f $1 ]]; then
sha1sum $1 | sed -e "s/$1/$1 (file)/g"
else
checksum=$(echo -n $1 | openssl sha1 | sed -e "s/(stdin)= //")
echo "$checksum \"$1\" (string)"
fi
}
function sha256() {
if [[ -f $1 ]]; then
sha256sum $1 | sed -e "s/$1/$1 (file)/g"
else
checksum=$(echo -n $1 | openssl sha256 | sed -e "s/(stdin)= //")
echo "$checksum \"$1\" (string)"
fi
}
function sha512() {
if [[ -f $1 ]]; then
sha512sum $1 | sed -e "s/$1/$1 (file)/g"
else
checksum=$(echo -n $1 | openssl sha512 | sed -e "s/(stdin)= //")
echo "$checksum \"$1\" (string)"
fi
}
#
# Docker
#
function dsh() {
docker exec -it $1 /bin/bash
}
#
# Files
#
# Counts the files.
function files() {
ls $1 | wc -l
}
#
# Hardware
#
# https://unix.stackexchange.com/a/119170/173034
function disk() {
df -h | awk '$NF=="/"{printf "Disk Usage: %d/%dGB (%s)\n", $3,$2,$5}'
}