3 ms·
I couldn't immediately tell from your reply whether you didn't know about pushd/popd or were mentioning them as something missing from the list. Since I don't s
by gmjosack 13y ago
I couldn't immediately tell from your reply whether you didn't know about pushd/popd or were mentioning them as something missing from the list. Since I don't seem to see them in the posted list I'm going to assume the latter.
For anyone who is curious about pushd/popd, pushd will change your current working directory and adds your new working directory to the top of a stack. popd will remove the top directory from the stack and change your current working directory to the new top of stack. This is helpful in scripts where you need to change directories for some action and then back out to where you were. You can also use the dirs command to list the stack.
One reason I could see omitting these from the list is that they are shell builtins rather than external commands as the vast majority of the list is.
- izietto 13y agoI use "cd -" all the time, it changes to the previous working directory
- gmjosack 13y agoYeah, whenever you cd, OLDPWD gets set to the directory you just changed from. cd will substitute $OLDPWD when you cd to "-". Perhaps even less well know, the shell itself will expand ~- to $OLDPWD so if you ever want to see where cd - would take you, or just list the files from your previous working directory you could do "echo ~-" or "ls ~-" respectively.
- oftenwrong 13y agoPWD, OLDPWD, and cd - are POSIX ~- is a bashism You can add a number to navigate the pushd/popd/dirs stack https://www.gnu.org/software/bash/manual/bashref.html#Tilde-Expansion https://www.gnu.org/software/bash/manual/bashref.html#Tilde-...