Blob


1 awk ' # rotate
2 # Input line: string (tab) ["b"|"e"|"a"] (tab) number
3 # Output several lines:
4 # string (tab) ["b"|"e"|"a"] (tab) number
5 # rotated string (tab) ["b"|"e"|"a"] (tab) number
6 # rotated string (tab) ["b"|"e"|"a"] (tab) number
7 # ...
8 #
9 # In the output strings, tildes are replaced by spaces
11 BEGIN { FS = OFS = "\t" }
13 / %key / { # if explicit sort.key is provided, do not rotate
14 print $0
15 next
16 }
18 {
19 t1 = $1 #t1 will be $1 with tildes changed to spaces
20 gsub(/%~/, "QQ5QQ", t1) #hide real tildes
21 gsub(/~/, " ", t1) #change tildes to spaces
22 gsub(/QQ5QQ/, "%~", t1) #restore real tildes
23 print t1, $2, $3
24 i = 1
25 while ((j = index(substr($1, i+1), " ")) > 0) {
26 i += j
27 printf("%s, %s\t%s\t%s\n", \
28 substr(t1, i+1), substr(t1, 1, i-1), $2, $3)
29 }
30 }
31 ' $*