Extract common bits of nearest and file commands