Ticket #1921: lslR.diff
File lslR.diff, 1.2 KB (added by storchaka, 15 years ago) |
---|
-
lslR.in
../ 24 24 $MYCAT "$1" | $AWK ' 25 25 BEGIN { 26 26 dir=""; 27 # Pattern to match 8 first fields.27 empty=1; 28 28 rx = "[^ ]+[ ]+"; 29 rx = "^" rx rx rx rx rx rx rx rx; 29 # Pattern to match 7 first fields. 30 rx7 = "^" rx rx rx rx rx rx "[^ ]+[ ]"; 31 # Pattern to match 8 first fields. 32 rx8 = "^" rx rx rx rx rx rx rx "[^ ]+[ ]"; 30 33 } 31 34 /^total\ [0-9]*$/ { next } 32 /^$/ { next } 33 /^[^ ].*:$/ { 35 /^$/ { empty=1; next } 36 empty==1 && /:$/ { 37 empty=0 34 38 if ($0 ~ /^\//) dir=substr($0, 2); 35 39 else dir=$0; 36 40 if (dir ~ /\/:$/) sub(/:$/, "", dir); 37 41 else sub(/:$/, "/", dir); 42 if (dir ~ /^[ ]/) dir="./"dir; 38 43 next; 39 44 } 40 ( $9 != "" ) { 45 ( NF > 7 ) { 46 empty=0 41 47 # gensub() is not portable. 42 48 name=$0 43 sub(rx, "", name) 44 # Cannot assign to $9, or spaces in the filename would be reduced. 45 attr=substr($0, 1, length($0)-length(name)) 46 printf "%s%s%s\n", attr, dir, name 49 i=index($6, "-") 50 if (i) { 51 sub(rx7, "", name) 52 NF = 7 53 $6=substr($6,i+1)"-"substr($6,1,i-1) 54 } 55 else { 56 sub(rx8, "", name) 57 NF = 8 58 } 59 printf "%s %s%s\n", $0, dir, name 60 } 61 { 62 empty=0 47 63 }' 48 64 } 49 65