linux mv命令 – 移動或改名文件
ls是最常被使用到的Linux命令之一,來自于英文單詞list的縮寫,也正如list單詞的英文意思,其功能是列舉出指定目錄下的文件名稱及其屬性。
默認(rèn)不加參數(shù)的情況下,ls命令會列出當(dāng)前工作目錄中的文件信息,經(jīng)常與cd和pwd命令搭配使用,十分方便。而帶上參數(shù)后,我們則可以做更多的事情,作為最基礎(chǔ)、最頻繁使用的命令,有必要仔細(xì)了解下其常用功能。
語法格式: ls [參數(shù)] [文件]
常用參數(shù):
-a 顯示所有文件及目錄 (包括以“.”開頭的隱藏文件)
-l 使用長格式列出文件及目錄的詳細(xì)信息
-r 將文件以相反次序顯示(默認(rèn)依英文字母次序)
-t 根據(jù)最后的修改時間排序
-A 同 -a ,但不列出 “.” (當(dāng)前目錄) 及 “..” (父目錄)
-S 根據(jù)文件大小排序
-R 遞歸列出所有子目錄
-d 查看目錄的信息,而不是里面子文件的信息
-i 輸出文件的inode節(jié)點信息
-m 水平列出文件,以逗號間隔
-X 按文件擴(kuò)展名排序
--color 輸出信息中帶有著色效果
參考實例
輸出當(dāng)前目錄中的文件(默認(rèn)不含隱藏文件):
[root@linuxcool ~]# ls
anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates
Desktop Downloads Music Public Videos
輸出當(dāng)前目錄中的文件(含隱藏文件):
[root@linuxcool ~]# ls -a
. .bashrc Documents Music Videos
.. .cache Downloads Pictures .viminfo
anaconda-ks.cfg .config .esd_auth .pki
.bash_history .cshrc .ICEauthority Public
.bash_logout .dbus initial-setup-ks.cfg .tcshrc
.bash_profile Desktop .local Templates
輸出文件的長格式,包含屬性詳情信息:
[root@linuxcool ~]# ls -l
total 8
-rw-------. 1 root root 1430 Dec 14 08:05 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Dec 14 08:37 Desktop
drwxr-xr-x. 2 root root 6 Dec 14 08:37 Documents
drwxr-xr-x. 2 root root 6 Dec 14 08:37 Downloads
-rw-r--r--. 1 root root 1585 Dec 14 08:34 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 6 Dec 14 08:37 Music
drwxr-xr-x. 2 root root 6 Dec 14 08:37 Pictures
drwxr-xr-x. 2 root root 6 Dec 14 08:37 Public
drwxr-xr-x. 2 root root 6 Dec 14 08:37 Templates
drwxr-xr-x. 2 root root 6 Dec 14 08:37 Videos
輸出指定目錄中的文件列表:
[root@linuxcool ~]# ls /etc
adjtime hosts pulse
aliases hosts.allow qemu-ga
alsa hosts.deny qemu-kvm
alternatives hp radvd.conf
anacrontab idmapd.conf ras
asound.conf init.d rc0.d
at.deny inittab rc1.d
………………省略部分輸出信息………………
輸出文件名稱及inode屬性塊號碼:
[root@linuxcool ~]# ls -i
35290115 anaconda-ks.cfg 35290137 initial-setup-ks.cfg 35290164 Templates
1137391 Desktop 17840039 Music 51609597 Videos
1137392 Documents 35290165 Pictures
17840038 Downloads 51609596 Public
搭配通配符一起使用,輸出指定目錄中所有以sd開頭的文件名稱:
[root@linuxcool ~]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2
依據(jù)文件大小進(jìn)行排序,輸出指定目錄中文件屬性詳情信息:
[root@linuxcool ~]# ls -Sl /etc
total 1348
-rw-r--r--. 1 root root 692241 Sep 10 2018 services
-rw-r--r--. 1 root root 66482 Dec 14 08:34 ld.so.cache
-rw-r--r--. 1 root root 60352 May 11 2017 mime.types
-rw-r--r--. 1 root dnsmasq 26843 Aug 12 2018 dnsmasq.conf
-rw-r--r--. 1 root root 25696 Dec 12 2018 brltty.conf
-rw-r--r--. 1 root root 9450 Aug 12 2018 nanorc
-rw-r--r--. 1 root root 7265 Dec 14 08:03 kdump.conf
-rw-------. 1 tss tss 7046 Aug 13 2018 tcsd.conf
………………省略部分輸出信息………………
作者:大學(xué)生新聞網(wǎng) 來源:大學(xué)生新聞網(wǎng)
- linux mv命令 – 移動或改名文件
- ls是最常被使用到的Linux命令之一,來自于英文單詞list的縮寫,也正如list單詞的英文意思,其功能是列舉出指定目錄下的文件名稱及其屬
- 03-12 關(guān)注:0
- C語言求最大公約數(shù)
- 如果有一個自然數(shù)a能被自然數(shù)b整除,則稱a為b的倍數(shù),b為a的約數(shù)。幾個自然數(shù)公有的約數(shù),叫做這幾個自然數(shù)的公約數(shù)。
- 03-12 關(guān)注:1
- C語言求勾股數(shù)
- 所謂勾股數(shù),是指能夠構(gòu)成直角三角形三條邊的三個正整數(shù)(a,b,c)。
- 03-11 關(guān)注:3