tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: test.1 -> "if file exists" -> "if pathname resolves to an existing directory entry"



> If you need a single (unraceable) test, that can often be achieved by
> attempting to make a link to the target filename, as link(2) and
> hence ln(1) without -f will fail if the target name exists.

Yes, but it requires that you're running as a user which can write to
the target filesystem, and, if the target doesn't exist, it will create
it.  For some purposes, stat -L might help, though in a small test I
just did that printed data for the link when applied to an existing
link whose target is nonexistent.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index