Skip to content

Instantly share code, notes, and snippets.

@adsr303
Created April 28, 2015 12:49
Show Gist options
  • Save adsr303/450e2ed6dd8899f78757 to your computer and use it in GitHub Desktop.
Save adsr303/450e2ed6dd8899f78757 to your computer and use it in GitHub Desktop.
Remove duplicate entries in UNIX path. Keeps the order of first occurences.
#!/usr/bin/awk -f
BEGIN {
RS = ":|\n"
}
{
if (data[$0]++ == 0)
lines[++count] = $0
}
END {
for (i=1; i<=count; i++) {
printf "%s", lines[i]
if (i < count)
printf ":"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment