Strangely enough this works better.
This commit is contained in:
malc 2016-05-24 21:04:23 +03:00
parent 9e91e3816d
commit 4dd6739c01

View file

@ -5,26 +5,19 @@ BEGIN {
RS = OFS = ORS = "\000"
}
# courtesy freenode#awk/izabera
function quote(str) {
gsub(/'/, "\\'", str);
return str
}
{
path = $0
getline time
qpath = quote(path)
r = stat(path)
data[1] = 1
if (stat(path, data) == -1) {
if ("locate -b -l 1 -e '/" qpath "$'" | getline npath > 0) {
if ("locate -b -l 1 -e \"/" path "$\"" | getline npath > 0) {
npath = ""
}
print path npath "\000";
if (!npath) {
print "Removing " qpath "\n" > "/dev/stderr"
print "Removing " path "\n" > "/dev/stderr"
}
}
}