-
Notifications
You must be signed in to change notification settings - Fork 0
/
awk.txt
46 lines (33 loc) · 949 Bytes
/
awk.txt
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
##################################################################################################
command : awk
section : Y
##################################################################################################
<cmd>
basic
awk -F: {'print $NF'}
using shell variable on awk
usege : '"${varialblename}"'
e.g : awk -F"[<>]" '/'"${section_name}"'/ {getline;print $1;exit}' $file_name
</cmd>
<var>
$NF : last filed
$NF-1 -2 ... -N
</var>
examples
#!/bin/sh
function run() {
echo $1
}
export -f run
DATA="u l h h l j h l k k k u l h h l k l j j h h h l u h h h h j k u l k k k k j l k k j j l u k k l
k k j k l u u u h h h l j j j j j k l u u k k k k k l u u k k k k k l k k l j h l k k k k k l u h l
j j h h h h l j j k k l j l u u h h h h l k l k l k l j j j j j l"
echo $DATA | awk '{
for(i=1;i<NF;i++)
print $i
}' > DATA_COND
while read -r line
do
command=$line
echo "command = $line"
done < DATA_COND