cat:由第一行開始顯示文件內(nèi)容
tac:由最后一行開始顯示文件內(nèi)容
nl:顯示的時(shí)候,順便輸出行號
more:一頁一頁的顯示文件內(nèi)容
less:與 more 類似,但是它可以往前翻頁
head:只看頭幾行
tail:只看結(jié)尾幾行
touch:文件創(chuàng)建與文件時(shí)間修改
語法:cat [-AbEnTv]
選項(xiàng)與參數(shù):
-A:相當(dāng)于-vET 的整合參數(shù)
-b:列出行號,僅針對非空白行做行號顯示
-n:輸出行號,空白與非空白都會列出
-E:將結(jié)尾的斷行字符¥顯示出來
-v:列出一些看不出的特殊字符
-T:將 Tab 按鍵以∧I 顯示出來
舉例:
[root@localhost tmp]# cat /etc/issue
CentOS release 5.10 (Final)
Kernel \r on an \m
[root@localhost tmp]# cat -n /etc/issue
1 CentOS release 5.10 (Final)
2 Kernel \r on an \m
3
[root@localhost tmp]# cat -A /etc/issue
CentOS release 5.10 (Final)$
Kernel \r on an \m$
$
語法 :[root@www ~]# nl [-bnw] 文件
選項(xiàng)與參數(shù):
-b:指定行號指定的方式,主要有兩種:
-b a :表示不論是否為空行,也同樣列出行號(類似 cat -n);
-b t :如果有空行,空的那一行不要列出行號(默認(rèn)值);
-n:列出行號表示的方法,主要有三種:
-n ln :行號在螢?zāi)坏淖钭蠓斤@示;
-n rn :行號在自己欄位的最右方顯示,且不加 0 ;
-n rz :行號在自己欄位的最右方顯示,且加 0 ;
-w:行號欄位的占用的位數(shù)。
舉例
[root@www ~]# nl /etc/issue
1 CentOS release 5.3 (Final)
2 Kernel \r on an \m
這個文件其實(shí)有三行,第三行為空白(沒有任何字節(jié)),
因?yàn)樗强瞻仔?,所?nl 不會加上行號喔
[root@www ~]# nl -b a /etc/issue
1 CentOS release 5.3 (Final)
2 Kernel \r on an \m
3
[root@www ~]# nl -b a -n rz /etc/issue
000001 CentOS release 5.3 (Final)
000002 Kernel \r on an \m
000003
自動在自己欄位的地方補(bǔ)上 0 了~默認(rèn)欄位是六位數(shù),如果想要改成 3 位數(shù)?
[root@www ~]# nl -b a -n rz -w 3 /etc/issue
001 CentOS release 5.3 (Final)
002 Kernel \r on an \m
003
語法:more|less文件
Less:
空白鍵 :向下翻動一頁;
[pagedown]:向下翻動一頁;
[pageup] :向上翻動一頁;
/字串 :向下搜尋『字串』的功能;
?字串 :向上搜尋『字串』的功能;
n :重復(fù)前一個搜尋 (與 / 或 ? 有關(guān)!)
N :反向的重復(fù)前一個搜尋 (與 / 或 ? 有關(guān)!)
q :離開 less 這個程序;
舉例:
[root@localhost tmp]# more /etc/man.config
#
# Generated automatically from man.conf.in by the
……..
# and to determine the correspondence between extensions and decompressors.
#
# MANBIN /usr/local/bin/man
#
--More--(31%)
語法:head [-nnumber] 文件
選項(xiàng)與參數(shù):
-n:后面接數(shù)字,代表行數(shù)
number 默認(rèn)值是10 當(dāng) number 是負(fù)數(shù),代表列出前面所有行數(shù)但是不包括后面 number 行
語法:tail [-nnumber] 文件
選項(xiàng)與參數(shù):
-n:后面接數(shù)字,代表行數(shù)
number 默認(rèn)值是10 當(dāng) number 是正數(shù)(+ number),代表該文件從 number 以后才會列出來
時(shí)間屬性
Mtime(modificationtime):當(dāng)文件內(nèi)容數(shù)據(jù)更改時(shí)就會更新這個時(shí)間,內(nèi)容數(shù)據(jù)指的是文件的內(nèi)容,不包括文件的權(quán)限和屬性
Ctime(Statetime):當(dāng)文件的狀態(tài)(權(quán)限和屬性)更改時(shí)會更新這個時(shí)間
Atime(accesstime):當(dāng)文件內(nèi)容被取用就會修改這個時(shí)間
舉例:
[root@localhost ~]# ls -l --time-style=long-iso /etc/man.config 默認(rèn)是修改mtime
-rw-r--r-- 1 root root 4617 2012-05-30 20:34 /etc/man.config
[root@localhost ~]# ls -l --time=ctime --time-style=long-iso /etc/man.config
-rw-r--r-- 1 root root 4617 2014-02-14 10:06 /etc/man.config
[root@localhost ~]# ls -l --time=atime --time-style=long-iso /etc/man.config
-rw-r--r-- 1 root root 4617 2014-02-21 10:19 /etc/man.config
語法:touch[-acdmt] 文件
選項(xiàng)與參數(shù):
-a:僅修改訪問時(shí)間 atime
-c:僅修改文件的時(shí)間,若該文件不存在則不創(chuàng)建新文件
-d:后面可接欲修改的日期,也可以使用—date=”時(shí)間或日期”
-m:僅修改 mtime
-t:后面可以接欲修改的時(shí)間
主要功能:
創(chuàng)建一個空文件
修改文件日期(mtime,atime)
舉例:
[root@localhost tmp]# cp -a /etc/man.config ./newman.config
[root@localhost tmp]# ls -l --time-style=long-iso newman.config 指定時(shí)間格式
-rw-r--r-- 1 root root 4617 2012-05-30 20:34 newman.config
[root@localhost tmp]# touch -m -t 0709150203 newman.config //只修改mtime
[root@localhost tmp]# ls -l --time-style=long-iso newman.config
-rw-r--r-- 1 root root 4617 2007-09-15 02:03 newman.config
[root@localhost tmp]# ls -l --time=atime --time-style=long-iso newman.config //只修改atime
-rw-r--r-- 1 root root 4617 2014-02-21 10:33 newman.config
[root@localhost tmp]# touch -a -t 0809150203 newman.config
[root@localhost tmp]# ls -l --time=atime --time-style=long-iso newman.config
-rw-r--r-- 1 root root 4617 2008-09-15 02:03 newman.config
[root@localhost tmp]#
[root@localhost tmp]# touch -d "2 days ago" newman.config //默認(rèn)修改atime 與 mtime
[root@localhost tmp]# ls -l --time=atime --time-style=long-iso newman.config
-rw-r--r-- 1 root root 4617 2014-02-19 10:36 newman.config
[root@localhost tmp]# ls -l --time-style=long-iso newman.config
-rw-r--r-- 1 root root 4617 2014-02-19 10:36 newman.config