第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

您好,linux下的ls和dir?兩者之間有什么不一樣?

您好,linux下的ls和dir?兩者之間有什么不一樣?

手掌心 2021-06-23 14:10:06
ls比dir好用, 那為什么linux下還要提供dir這個命令呢? 是一種對于老用戶的照顧?
查看完整描述

2 回答

?
猛跑小豬

TA貢獻1858條經(jīng)驗 獲得超8個贊

名稱: ls 使用權(quán)限 : 所有使用者 使用方式 : ls [-alrtAFR] [name...] 說明: 顯示指定工作目錄下之內(nèi)容(列出目前工作目錄所含之檔案及子目錄)。 -a 顯示所有檔案及目錄 (ls內(nèi)定將檔案名或目錄名稱開頭為"."的視為隱藏檔,不會列出) -l 除檔案名稱外,亦將檔案型態(tài)、權(quán)限、擁有者、檔案大小等資訊詳細列出 -r 將檔案以相反次序顯示(原定依英文字母次序) -t 將檔案依建立時間之先后次序列出 -A 同 -a ,但不列出 "." (目前目錄) 及 ".." (父目錄) -F 在列出的檔案名稱后加一符號;例如可執(zhí)行檔則加 "*", 目錄則加 "/" -R 若目錄下有檔案,則以下之檔案亦皆依序列出 ls的功能只有這么多 但是dir還有和ls不同的命令用法 例如: 名稱:rmdir 使用權(quán)限:于目前目錄有適當權(quán)限的所有使用者 使用方式: rmdir [-p] dirName 說明: 刪除空的目錄。 參數(shù): -p 是當子目錄被刪除后使它也成為空目錄的話,則順便一并刪除。

查看完整回答
反對 回復 2021-06-27
?
嗶嗶one

TA貢獻1854條經(jīng)驗 獲得超8個贊

dir 和 ls 都是軟件包 coreutils 的一部分還有一個 vdir 也是一樣。這兩個命令幾乎相同,只是具有不同的默認選項,可以通過 info 指令獲得它們的信息:

10.1 ‘ls’: List directory contents

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

The ‘ls’ program lists information about files (of any type, including

directories).  Options and file arguments can be intermixed arbitrarily,

as usual.

For non-option command-line arguments that are directories, by

default ‘ls’ lists the contents of directories, not recursively, and

omitting files with names beginning with ‘.’.  For other non-option

arguments, by default ‘ls’ lists just the file name.  If no non-option

argument is specified, ‘ls’ operates on the current directory, acting as

if it had been invoked with a single argument of ‘.’.

By default, the output is sorted alphabetically, according to the

locale settings in effect.(1)  If standard output is a terminal, the

output is in columns (sorted vertically) and control characters are

output as question marks; otherwise, the output is listed one per line

and control characters are output as-is.

Because ‘ls’ is such a fundamental program, it has accumulated many

options over the years.  They are described in the subsections below;

within each section, options are listed alphabetically (ignoring case).

The division of options into the subsections is not absolute, since some

options affect more than one aspect of ‘ls’’s operation.

10.2 ‘dir’: Briefly list directory contents

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

‘dir’ is equivalent to ‘ls -C -b’; that is, by default files are listed

in columns, sorted vertically, and special characters are represented by

backslash escape sequences.

10.3 ‘vdir’: Verbosely list directory contents

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

‘vdir’ is equivalent to ‘ls -lb’; that is, by default files are listed

in long format and special characters are represented by backslash

escape sequences.

大概意思就是說 dir 和 vdir 兩個指令相當于 ls 指令加上一些其他參數(shù),沒有其他明顯區(qū)別。

特別的,許多人認為 dir 是 ls 的別名,但事實并非如此。這兩個命令都不是另一個的別名,默認情況下,在 Ubuntu 中, dir 根本不是別名。 ls 和 dir 由單獨的 non-identical 可執(zhí)行文件提供。

單獨的 dir 實用程序的基本原理在 GNU coding standards 的 4.5 Standards for Interfaces Generally 中給出。

Please don’t make the behavior of a utility depend on the name used to invoke it….

Instead, use a run time option or a compilation switch or both to select among the alternate behaviors….

Likewise, please don’t make the behavior of a command-line program depend on the type of output device….

Compatibility requires certain programs to depend on the type of output device. It would be disastrous if ls or sh did not do so in the way all users expect. In some of these cases, we supplement the program with a preferred alternate version that does not depend on the output device type. For example, we provide a dir program much like ls except that its default output format is always multi-column format.

大概意思是說 ls 指令由于兼容性需要,無法作為獨立運行設備編寫,故另外單獨編寫了 dir 和 vdir 指令作為 device-independent 輸出(而 ls 指令是 device-dependent 類型的)。相比于 ls 來說,這兩個指令雖然在默認情況下調(diào)用和 ls 的帶參數(shù)調(diào)用相當,但是這兩個指令提供了一些額外的選項組合。

大多數(shù)人覺得 ls 比 dir 好用的原因是在默認情況下很多 linux 分發(fā)版的 .bashrc 將 ls 定義為 ls --color=auto 的別名,這樣造成了 ls 的輸出帶有不同的顏色標識而 dir 與 vdir 沒有。下面是 Ubuntu 的 .bashrc 文件片段:

if [ -x /usr/bin/dircolors ]; then

test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"

alias ls='ls --color=auto'

#alias dir='dir --color=auto'

#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'

alias fgrep='fgrep --color=auto'

alias egrep='egrep --color=auto'

fi

# some more ls aliases

alias ll='ls -alF'

alias la='ls -A'

alias l='ls -CF'

可以看到 .bashrc 文件中貼心地為 ls 指令添加了很多別名,但是 dir 和 vdir 的別名被注釋掉了。這也就造成了為什么 ls 比 dir 好用的原因。

要使用 dir 啟用彩色輸出,只需在主目錄中編輯 .bashrc 文件,然后通過刪除前導 # 取消注釋 #alias dir='dir --color=auto' 行。在更改后啟動的 shell 中, dir 將成為別名,輸入 dir 指令也可以產(chǎn)生不同的色彩高亮標識。而當作為外部命令調(diào)用時,例如在腳本中或通過運行 \dir 或 command dir 覆蓋別名時, dir 仍將產(chǎn)生 device-independent 輸出。這就是說,將 dir 別名化為 dir --color=auto 并不會真正破壞 dir 。



查看完整回答
反對 回復 2021-06-27
  • 2 回答
  • 0 關注
  • 602 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號