-
Notifications
You must be signed in to change notification settings - Fork 1
/
.functions
66 lines (64 loc) · 2.37 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
64
65
66
# https://github.com/mathiasbynens/dotfiles/blob/master/.functions
fs () {
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh;
else
local arg=-sh;
fi
if [[ -n "$@" ]]; then
du $arg -- "$@";
else
du $arg .[^.]* ./*;
fi;
}
mkcd () {
mkdir -p $1 ;
cd $1
}
lf () {
ls $1 | wc -l
}
myip () {
ifconfig | grep "inet addr" | head -n1 | sed -e 's/.*r://' -e 's/ .*//'
}
ldup () {
for f in $(ls $1/duplicity-*.manifest.gpg); do
echo "========================================================================";
echo $f;
n=$(basename $f .manifest.gpg);
prefix=$(echo $n | awk 'BEGIN { FS = "." } ;{ print $1 }');
if [[ "$prefix" == "duplicity-full" ]]; then
t=$(echo $n | awk 'BEGIN { FS = "." } ;{ print $2 }');
else
t=$(echo $n | awk 'BEGIN { FS = "." } ;{ print $4 }');
fi;
echo -e "Creation time:\t" $t;
echo "------------------------------------------------------------------------";
duplicity list-current-files --time $t file://$1/ | grep "$2";
done;
}
calctimeone () {
tail $1 | grep "cpu time" | sed -e 's/^.*: *//' | awk '{total = ($1 * 24) + ($3) + ($5 / 60) + ($7 / 3600) } END {print total }'
}
calctime () {
tail *.log | grep "cpu time" | sed -e 's/^.*: *//' | awk '{total += ($1 * 24) + ($3) + ($5 / 60) + ($7 / 3600) } END {print total }'
}
calctime2 () {
grep "cpu time" *.log | sed -e 's/^.*: *//' | awk '{total += ($1 * 24) + ($3) + ($5 / 60) + ($7 / 3600) } END {print total }'
}
calctime3 () {
num=$(ls *.log | wc -l);
grep "cpu time" *.log | sed -e 's/^.*: *//' | awk -v num="$num" '{total += ($1 * 24) + ($3) + ($5 / 60) + ($7 / 3600) } END {print total/num }'
}
gstat () {
for f in $@ ; do
echo $f $(ls $f/*.log 2> /dev/null | wc -l) $( grep 'Normal termination' $f/*.log 2> /dev/null | wc -l ) $( ls $f/*.gjf 2> /dev/null | wc -l);
done
}
swap () {
TMPFILE=$(mktemp $(dirname "$1")/XXXXXX)
mv "$1" "$TMPFILE" && mv "$2" "$1" && mv "$TMPFILE" "$2";
}
latency () {
curl -L -w "\ntime_namelookup: %{time_namelookup}\ntime_connect: %{time_connect}\ntime_appconnect: %{time_appconnect}\ntime_pretransfer: %{time_pretransfer}\ntime_redirect: %{time_redirect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" $1 2>/dev/null | tail -n7
}