偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

在 Linux 中使用 pushd 和 popd 進行高效的文件目錄導航

系統(tǒng) Linux
本教程將解釋一組Linux命令:“ pushd ”和“ popd ”,它們用于高效導航 Linux 目錄結(jié)構(gòu)。它們存在于大多數(shù) shell 中,例如 bash、tcsh 等。

 [[406787]]

有時,使用命令瀏覽 Linux 文件系統(tǒng)可能會很痛苦,尤其是對于新手而言。通常,我們主要使用cd(更改目錄)命令來移動 Linux 文件系統(tǒng)。

本教程將解釋一組Linux命令:“ pushd ”和“ popd ”,它們用于高效導航 Linux 目錄結(jié)構(gòu)。它們存在于大多數(shù) shell 中,例如 bash、tcsh 等。

在 Linux 中pushd 和 popd 命令是如何工作的

pushd和popd根據(jù)“ LIFO ”(后進先出)原則工作。在這個原則中,只允許兩種操作:將一個項目壓入堆棧,以及從堆棧中彈出一個項目。

pushd 在棧頂添加一個目錄,popd 從棧頂刪除一個目錄。

要顯示目錄堆棧(或歷史記錄)中的目錄,我們可以使用dirs命令,如圖所示。 

  1. [linuxmi@localhost ~/www.linuxmi.com/linuxmi]$dirs  
  2. ~/www.linuxmi.com/linuxmi  
  3. 或者  
  4. [linuxmi@localhost ~/www.linuxmi.com/linuxmi]$dirs -v 
  5.  0 ~/www.linuxmi.com/linuxmi 

 

pushd 命令- 將目錄路徑放入/添加到目錄堆棧(歷史記錄)中,稍后允許您導航回歷史記錄中的任何目錄。當您將目錄添加到堆棧時,它也會回顯歷史(或“堆棧”)中存在的內(nèi)容。

這些命令顯示了 pushd 的工作原理: 

  1. [linuxmi@localhost ~/www.linuxmi.com]$pushd /var/www/html/  
  2. /var/www/html ~/www.linuxmi.com  
  3. [linuxmi@localhost /var/www/html]$pushd /home/linuxmi/web/wp-admin  
  4. ~/web/wp-admin /var/www/html ~/www.linuxmi.com  
  5. [linuxmi@localhost ~/web/wp-admin]$pushd /mnt/hgfs  
  6. /mnt/hgfs ~/web/wp-admin /var/www/html ~/www.linuxmi.com  
  7. [linuxmi@localhost /mnt/hgfs]$pushd /test  
  8. /test /mnt/hgfs ~/web/wp-admin /var/www/html ~/www.linuxmi.com 

pushd - 將目錄添加到堆棧

從上面輸出中的目錄堆棧可以看到(目錄索引順序相反): 

  1. [linuxmi@localhost /test]$dirs -v  
  2. 0 /test  是目錄堆棧中的第五個 [索引為 0]。  
  3. 1 /mnt/hgfs  是目錄堆棧中的第四個 [索引為 1]。  
  4. 2 ~/web/wp-admin  是目錄堆棧中的第三個 [索引為 2]。  
  5. 3 /var/www/html  是目錄堆棧中的第二個 [索引為 3]。  
  6. 4 ~/www.linuxmi.com 是目錄堆棧中的第一個 [索引為 1]。 

或者,我們可以使用表單中的目錄索引pushd +# 或 pushd -#將目錄添加到堆棧中。要進入/var/www/html,我們將輸入: 

  1. [linuxmi@localhost /test]$pushd +3  
  2. /var/www/html ~/www.linuxmi.com /test /mnt/hgfs ~/web/wp-admin 

注意在此之后,堆棧內(nèi)容將發(fā)生變化。因此,從前面的示例中,要進入~/www.linuxmi.com,我們將使用: 

  1. [linuxmi@localhost /var/www/html]$pushd +1  
  2. ~/www.linuxmi.com /test /mnt/hgfs ~/web/wp-admin /var/www/html 

pushd - 用號碼導航目錄

popd 命令——從堆?;驓v史記錄的頂部刪除一個目錄。要列出目錄堆棧,請鍵入: 

  1. [linuxmi@localhost ~/www.linuxmi.com]$popd  
  2. /test /mnt/hgfs ~/web/wp-admin /var/www/html  

要從目錄堆棧中刪除目錄,請使用popd +# 或 popd -#,在這種情況下,我們將鍵入以下命令以刪除/mnt/hgfs: 

  1. [linuxmi@localhost /test]$popd +1  
  2. /test ~/web/wp-admin /var/www/html 

popd – 從堆棧中刪除目錄

在本教程中,我們解釋了用于導航目錄結(jié)構(gòu)的“pushd ”和“ popd ”命令。 

 

責任編輯:龐桂玉 來源: Linux公社
相關推薦

2012-05-11 10:22:26

Linuxdirspushd

2009-07-31 17:21:28

linux cd命令linux cd命令詳Pushd

2021-09-21 15:44:02

LinuxOBSWayland

2014-05-26 09:50:19

訪問控制列表ACL文件保護

2009-10-27 13:10:49

linux cd命令

2017-04-05 14:10:55

Linux命令行工具技巧

2009-12-14 13:33:31

linuxramdisk文件系統(tǒng)

2021-12-12 09:19:16

find命令Linux

2009-02-27 17:15:05

XMLDOMXPath

2020-07-29 07:40:19

Linux系統(tǒng)Vim

2018-06-01 10:37:26

Linux歸檔文件壓縮文件

2019-04-08 16:15:26

Linuxbd命令父目錄

2012-05-09 10:38:37

2023-07-04 16:36:03

Linuxcd 命令

2023-07-23 19:26:18

Linuxcat 命令

2013-05-14 10:13:06

WindowsLinux操作系統(tǒng)

2023-08-12 15:05:26

Linuxcp 命令

2011-12-08 10:24:53

JavaNIO

2023-10-28 16:22:21

Go接口

2021-11-29 22:59:34

Go Dockertest集成
點贊
收藏

51CTO技術棧公眾號