changing to parent directory in unix

2019-04-20 03:53发布

in general we use

cd .. for going to the parent directory

cd ../../ to go to the parents parent directory. and

cd ../../../../../ for 5th parent directory.

is there any simplified way of doing this?

shell i am using is ksh.

10条回答
一夜七次
2楼-- · 2019-04-20 04:30

If you don't like typing or remembering file names, you can navigate directories with something like NerdTree?

查看更多
时光不老,我们不散
3楼-- · 2019-04-20 04:31

And I thought I was lazy...

Long ago, I got tired of typing cd .. so, since roughly 1988 one of my standard aliases (and batch files for MSDOS/Windows) is up. Perhaps I should extend the concept:

alias up='cd ..'
alias up2='cd ../..'
alias up3='cd ../../..'
alias up4='cd ../../../..'
alias up5='cd ../../../../..'
alias up6='cd ../../../../../..'
查看更多
\"骚年 ilove
4楼-- · 2019-04-20 04:37

use cd / to go to the root of you filesystem, and cd ~ to go to you home directory.
Example: to go to you log director just do cd /var/log.

查看更多
Juvenile、少年°
5楼-- · 2019-04-20 04:38

You could define aliases to simplify this kind of cd operation.

Note that it would be easy to make errors with an alias in terms of ../../../.. etc, because you would have to be very sure of the relationship between your current directory and where you wanted to be.

Better to use absolute paths with alias

查看更多
登录 后发表回答