command line - When would multiple `///` be used between sub-directories? - Ask Ubuntu
i digging through /var/log/plymouth-debug.log
, spotted line:
[main.c:716] get_cache_file_for_mode:returning cache file '/var/lib/plymouth//boot-duration'
i thought typo typed following , sure enough can have many ///
between sub-directories , file name want. example:
rick@dell:~$ ls -la /var/lib/plymouth/boot-duration -rw-r--r-- 1 root root 2041 nov 3 21:39 /var/lib/plymouth/boot-duration ──────────────────────────────────────────────────────────────── rick@dell:~$ ls -la /var/lib/plymouth/////boot-duration -rw-r--r-- 1 root root 2041 nov 3 21:39 /var/lib/plymouth/////boot-duration ──────────────────────────────────────────────────────────────── rick@dell:~$ ls -la /var/lib//plymouth///boot-duration -rw-r--r-- 1 root root 2041 nov 3 21:39 /var/lib//plymouth///boot-duration
under circumstances want use 2 or more //
instead of single /
separator?
this answered nicely gilles on @ unix & linux: how linux handle multiple consecutive path separators (/home////username///file)?
multiple slashes allowed , equivalent single slash. single unix specification (version 3), base definitions §3.266 pathname: “multiple successive slashes considered same 1 slash.”
there 1 exception: if pathname starts 2 slashes, may treated differently (ref: base definitions §4.11 pathname resolution). linux doesn't this, though applications might, , other unix-ish system (e.g. cygwin).
a trailing
/
@ end of pathname forces pathname refer directory. in (posix 1003.1-2001 (single unix v3) base definitions §4.11 pathname resolution, trailing/
equivalent trailing/.
. posix 1003.1-2008 (single unix v4) base definitions §4.12 removes requirement make equivalent/.
, in order cope non-existing directories (e.g.mkdir foo/
required work, whereasmkdir foo/.
wouldn't — see rationale change).for programs act on directory entry, if
foo
symbolic link directory, passingfoo/
way make program act on directory instead of symbolic link.¹ note applies pathname resolution only, i.e. when accessing files. filename manipulations may work differently. example
basename
,dirname
ignore trailing slashes.
in case, i'm assuming ///
programming over-cautiousness (some dev using /
join paths when have trailing or leading slashes respectively).
Comments
Post a Comment