Directory
ls 沒有給我與 cd + ls 相同的文件夾
$> ls ../../../../..
沒有給我相同的結果
$> cd ../../../../.. $> ls
為什麼?有連結的東西?這是怎麼回事?
[ johanrj@jamin ] ~/XXX/broadcom/asuswrt/release/src-rt-6.x/linux/linux-2.6/drivers/net/phy/WRT/openwrt-git-8.09.2/package/swconfig/src $> ls ../../../../.. 9145-D5B0 asuswrt BCM53125 bcm_switch jrj Packages workspace [ johanrj@jamin ] ~/XXX/broadcom/asuswrt/release/src-rt-6.x/linux/linux-2.6/drivers/net/phy/WRT/openwrt-git-8.09.2/package/swconfig/src $> cd ../../../../.. [ johanrj@jamin ] ~/XXX/broadcom/asuswrt/release/src-rt-6.x/linux/linux-2.6/drivers/net/phy $> ls adm6996.c cicada.c libphy.ko lxt.c mdio-boardinfo.h mdio_bus.o phy_device.c smsc.c swconfig.mod.c WRT adm6996.h davicom.c libphy.mod.c Makefile mdio_bus.c Module.symvers phy_device.o swconfig.c swconfig.mod.o b53 fixed.c libphy.mod.o marvell.c mdio_bus.c.orig phy.c phy.o swconfig.ko swconfig.o broadcom.c Kconfig libphy.o mdio-boardinfo.c mdio_bus.c.rej phy.c.orig qsemi.c swconfig_leds.c vitesse.c
是的,您的 shell 在更改到符號連結目錄時會嘗試變得聰明:
$ mkdir a $ ln -s a b $ cd b $ pwd /home/michas/b $ pwd -P /home/michas/a
更改為符號連結後,
b
您的外殼會假裝您確實在“目錄”中b
,但符號連結將您發送到目錄a
。見
help pwd
:-P print the physical directory, without any symbolic links
外部命令(如
ls
)將始終使用物理路徑,但 shell 內置預設使用虛擬符號連結路徑。該
cd
命令是內置的 shell,預設解釋cd ..
為“保留目前符號連結”,而不是“使用物理父級”。但是你可以改變這種行為。help cd
說:-P use the physical directory structure without following symbolic links: resolve symbolic links in DIR before processing instances