Linux Alternative switching path mode pushd and POPD

Source: Internet
Author: User

PUSHD switch to the specified path
POPD back to the last directory
======================================
PUSHD can switch to the path specified later,Accumulate stack directories by the way
Stack: This is called a stack of pushd-accumulating directories
[Email protected] etc]# pushd/etc/sysconfig/network-scripts/
/etc/sysconfig/network-scripts/etcThese two directories are cumulative stacks

Accumulate a stack directory again/test
[Email protected] network-scripts]# pushd/test/
/test/etc/sysconfig/network-scripts/etc

Dirs can view the stack directory that is currently accumulating, or you can empty the stack with dirs-c
[Email protected] test]# dirs
/test/etc/sysconfig/network-scripts/etc

Each time the pushd switches to the 2nd directory in the Stack
[Email protected] etc]# pushd
/test/etc/etc/sysconfig/network-scripts

You can pushd +1 to move the stack directory forward, by the way into the back row in the first directory
[Email protected] etc]# pushd +1
/etc/sysconfig/network-scripts/test/etc

You can add more numbers to move more directories:
[Email protected] network-scripts]# pushd +2
/etc/etc/sysconfig/network-scripts/test

======================================
POPD back to the last directory you went to.

======================================

In the actual application of the popd and pushd commands, it comes in handy when writing shell scripts-you don't have to remember where you came from, and as long as you execute popd, you can go back to your directory.

This article from "crazywing" blog, reproduced please contact the author!

Linux Alternative switching path mode pushd and POPD

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.