這節(jié)練習(xí)中你將學(xué)習(xí)如何使用 ls 命令列出一個(gè)目錄下的所有內(nèi)容。
開始之前,確認(rèn)你已經(jīng) cd 回到 temp 的上一層目錄。.如果你不知道你在哪里,使用 pwd 找到你的位置,然后移動(dòng)到正確的目錄下。
$ cd temp
$ ls
stuff
$ cd stuff
$ ls
things
$ cd things
$ ls
frank
$ cd frank
$ ls
joe
$ cd joe
$ ls
alex
$ cd alex
$ ls
$ cd john
$ ls
$ cd ..
$ ls
john
$ cd ../../../
$ ls
frank
$ cd ../../
$ ls
stuff
$
> cd temp
> ls
Directory: C:\Users\zed\temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM stuff
> cd stuff
> ls
Directory: C:\Users\zed\temp\stuff
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM things
> cd things
> ls
Directory: C:\Users\zed\temp\stuff\things
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM frank
> cd frank
> ls
Directory: C:\Users\zed\temp\stuff\things\frank
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM joe
> cd joe
> ls
Directory: C:\Users\zed\temp\stuff\things\frank\joe
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM alex
> cd alex
> ls
Directory: C:\Users\zed\temp\stuff\things\frank\joe\alex
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM john
> cd john
> ls
> cd ..
> ls
Directory: C:\Users\zed\temp\stuff\things\frank\joe\alex
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM john
> cd ..
> ls
Directory: C:\Users\zed\temp\stuff\things\frank\joe
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM alex
> cd ../../..
> ls
Directory: C:\Users\zed\temp\stuff
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM things
> cd ..
> ls
Directory: C:\Users\zed\temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/17/2011 9:03 AM stuff
>
ls 能列出你當(dāng)前目錄中的所有內(nèi)容。你可以看到我用 cd 切換到不同的目錄下,然后列出該目錄下的所有內(nèi)容,這樣,我就知道我接下來要到哪個(gè)目錄中去了。
ls 命令有很多的命令選項(xiàng),當(dāng)我們學(xué)習(xí) help 命令之后,你將會(huì)學(xué)習(xí)如何得到這些命令選項(xiàng)的幫助信息。
- 輸入這里的每一個(gè)命令!你必須親手輸入這些命令來學(xué)習(xí)他們。只是讀他們并不夠。
- 在 Unix 中, 在 temp 目錄下試試命令 ls -lR。
- 在 Windows 中也可以試試 dir -R.
- 使用 cd 進(jìn)入到你計(jì)算機(jī)上的其他目錄,然后使用 ls 看看當(dāng)前目錄里有什么。
- 將你遇到的新問題更新到你的筆記本中。我知道你可能已經(jīng)有一些問題了,因?yàn)槲也]有覆蓋這些命令的所有點(diǎn)。
- 記住,如果你迷路了,使用 ls 和 pwd 找到你在哪里,然后使用 cd 去到你要去的目錄。