45 | | flag==1 { |
46 | | split($5, a, "-") |
47 | | if (index($1, "D") != 0) |
48 | | $1="drwxr-xr-x" |
49 | | else |
50 | | if (index($1, ".") != 0) |
51 | | $1="-rw-r--r--" |
52 | | printf "%s 1 %s %s %d %02d/%02d/%02d %s ./%s\n", $1, uid, gid, $2, a[2], a[1], a[3], $6, $8 |
| 45 | flag == 1 { |
| 46 | name=""; delete fields; delete seps; |
| 47 | |
| 48 | ### split line, save n-fields and save seperators in "seps" |
| 49 | ### tested with busybox awk |
| 50 | nameparts = split($0, fields, " "); |
| 51 | split($0, seps, "[^ \t]+"); |
| 52 | sub("^ ", "", seps[8]); |
| 53 | |
| 54 | ### split date for reformatting |
| 55 | split(fields[5], date, "-"); |
| 56 | |
| 57 | ### check/adjust rights |
| 58 | if (index(fields[1], "D") != 0) { |
| 59 | fields[1] = "drwxr-xr-x"; |
| 60 | } else { |
| 61 | if (index(fields[1], ".") != 0) { |
| 62 | fields[1] = "-rw-r--r--"; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | ### join filename from fields 8 .. nameparts (saved above) |
| 67 | for(i = 8; i <= nameparts; i++) { |
| 68 | name=name seps[i] fields[i]; |
| 69 | } |
| 70 | name=name seps[i]; |
| 71 | |
| 72 | ### remove padding blanks from short names |
| 73 | if (length(name)<13) { |
| 74 | sub(" *$", "", name); |
| 75 | } |
| 76 | |
| 77 | printf("%s 1 %s %s %d %02d/%02d/%02d %s ./%s\n", |
| 78 | fields[1], uid, gid, fields[2], date[2], |
| 79 | date[1], date[3], fields[6], name); |