On 2019-Oct-21 16:13:54 +0530, Abhinav Rajagopalan <abhinavrajagopalan(a)gmail.com>
wrote:
We should also touch upon the "cd -" as this
one takes you back like a back
button into the directory you were last inside, whereas the cd ../.. takes
you up or down the hierarchy depending on the placement of the / and adding
placeholders i.e directory names in place of the .. (dots).
There are two different mechanisms here. "-" as a "cd" argument is a
relatively recent shell builtin: More modern shells keep track of the
previous working directory ($OLDPWD) and evaluate "cd -" as "cd
$OLDPWD",
which will return to the previous working directory (modulo filesystem
changes). Note that it's a "swap" operation, not a "back"
operation:
Repeated "cd -" invocations will swap between two directories, not keep
going back through previous working directorie. I'm not sure when this
feature was introduced but don't believe it was part of ancient Unix.
OTOH, "cd ../.." just passes "../.." to the kernel as a pathname and
the
kernel evaluates it using its normal pathname lookup. Having it move
up (towards the root of) the filesystem relies on the presence of a ".."
directory entry being the parent directory inode.
Since you mentioned the word dd, the utility which
serves me like none
other for my frequent rewrites of images, it too has an interesting past,
it seems like 'dd' was non-unixy in it's design approach, if I'm to
believe
the lores around, which leads me to think that this might have been another
one of the many idiosyncratic naming conventions used back then. More on
the dd stuff:
http://www.catb.org/jargon/html/D/dd.html
As noted in the jargon file, the dd(1) syntax is deliberately reminiscent
of the DD statement in IBM JCL. This was presumably a joke and one of the
BTL old-timers on the list may know more of the background.
--
Peter Jeremy