-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaw
executable file
·49 lines (46 loc) · 1.45 KB
/
aw
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
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: aw
# Created: Thursday, 2020/09/22 - 12:58:16
# Author.: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Friday, 2023/05/26 - 23:41:21
# Modified By..: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 1.0.1.22
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# > wrapper for awk command
# ############################################################################
# HISTORY:
#
if [[ "$@" =~ "-" ]];then
# has an interval to cut?
fst=$(echo $1 | cut -d '-' -f1)
lst=$(echo $1 | cut -d '-' -f2)
awk_args=' BEGIN {
first = '$fst'; last = '$lst' \
} { \
for (i = first; i < last; i++) { \
printf("%10s ", $i) \
} printf("%10s", $last) \
}'
else
# creat awk syntax for values
awk_args="{printf("
while [ "$1" != "" ]; do
pf_s+="%s"
pf_p+=',$'$1
shift
if [ "$1" != "" ]; then
pf_s+=":"
fi
done
awk_args+="\"$pf_s\n\"$pf_p)}"
fi
# use column so separete results
cat - | while read LINE ; do
echo "${LINE}" | awk "$awk_args" | column -t -s ':'
done