Platform: CentOS 6.2 Shell:tcsh
I'm playing around with cd for a BASH script, and noticed the wondrous cd - option, but was left with many questions...
- Why the
cd -? Isn't this redundant withcd ..?
EDIT
[As FatalError points out, these two commands don't do the same things... so the answer is "no"]
- Can you delve farther back into your history with
-flag, a la in a browser?
e.g. When I typecd -, it takes me to my previous directory, but then if I enter that command again, it takes me to the directory I just came from, creating a sort of loop.
Is a shorthand for going back multiple levels supported?
EDIT
I realize I can go back withcd .., but was hoping this could be a gateway to a less verbose deep back, e.g.cd -3vs.cd ../../../... hopefully that clarifies what I'm asking....
EDIT2
As to the current feedback, while..is a special directory, I don't see a reason why the built-incdto the terminal couldn't use a shorthand for../../ ... ../e.g.cd ..5or why the built-in also couldn't have a history (a la autopushd/popd) that could be turned on and used likecd -3. I get that this could be somewhat of security/privacy risk, but I don't see how it's any worst than storing a command history, which most shells/terminals do.
- The manpage for
cd, accessible viaman cdandhelp cd(it's the same for either command), only lists-Land-Pflags.
However when I type incd --helpit outputsUsage: cd [-plvn][-|<dir>]..
Am I right in assuming the other flags and the - (back) option are nonstandard?
- What are the
-nand-vflags for?
Both seem to take me back to my home directory, that's all I've been able to figure out via experimentation.
A quick read on web resources [1][2] offered just the same sort of info that the man page did and didn't answer my questions.
Note: The second Linux-centric resource above claimed cd only had two options (obviously not true in current CentOS) hence my assumption that this functionality could be non-standard.
tcshcalledcdand not invoking/bin/cd(unless you explicitly specify/bin/cdon the command line) - this probably accounts for the difference in behavior. I'm not knowledgeable enough abouttcshto help you further, though. Try typinghelp cd(that's forbash, don't know how it will work ontcsh...) – ultrasawblade Apr 25 '12 at 20:21/bin/cdwould be pretty pointless (cdpretty much has to be a builtin to be useful). I'm pretty sure it only exists to satisfy some obscure POSIX requirement. – FatalError Apr 25 '12 at 20:30tcshspecific... that's kind of odd. I still am curious what the extra flags do.help cdprints the same info asman cd, like I mentioned... no clue as to what the extra flags in thetcshbuilt-in are for. – Jason R. Mick Apr 25 '12 at 20:31cd ..": note that command history enables you to docd .. <Enter> <Up> <Enter> <Up>and so on to quickly traverse backwards through the file tree. Perhaps I mostly find this more convenient because of my specific keyboard locale where/is behind the shift modifier, though. – Daniel Andersson Apr 25 '12 at 20:56cd ..littering your command history, which is less than optimal. acd ..5built in would not only be less typing and easy to implement, it'd also leave your history cleaner. It's amazing to me that I'm possibly the first to have thought of it. :P – Jason R. Mick Apr 25 '12 at 21:37