Attribution
[llpp.git] / misc / gc.awk
blobcaf5ffb1384321f423d9f4335888d5d4dc329d36
1 #!/usr/bin/gawk -f
2 @load "filefuncs"
4 BEGIN {
5 RS = OFS = ORS = "\000"
8 # courtesy freenode#awk/izabera
9 function quote(str) {
10 gsub(/'/, "\\'", str);
11 return str
15 path = $0
16 getline time
18 qpath = quote(path)
19 r = stat(path)
20 data[1] = 1
21 if (stat(path, data) == -1) {
22 if ("locate -b -l 1 -e '/" qpath "$'" | getline npath > 0) {
23 npath = ""
25 print path npath "\000";
26 if (!npath) {
27 print "Removing " qpath "\n" > "/dev/stderr"