On Mon, Feb 09, 2026 at 10:29:53 -0500, Eric Lovejoy via Bug reports for the
GNU Bourne Again SHell wrote:
> One Feature I would like to propose is an addition to the Bash shell
> builtin cd,
>
> cd -N :: change dir by N directories.
> $cd -3 # go up 3 directories.
> $cd -0 # no operation
> $cd -2 # go up 2 directories
> Goal save some key strokes? avoid this: cd ../../../../ type of thing.
> scripting possibilities?
>
>
> Potential downside:
> naming directories "-7" or any negative number might cause an issue in
> directory traversal.
You could implement this yourself with a function. I would suggest
not overriding the "cd" name, however, precisely because of the downside
you've already mentioned. A different name like "up" might be better.
Then you can also omit the - sign on the call.
up() {
local i
for ((i=0; i < $1; i++)); do cd .. || return 1; done
}