1-3 查看及检索文件
2016.6.2
cat
1.作用:显示文件内容
2.命令格式:cat [选项] 文件名 ...
concatenation (n.)
c. 1600, from Late Latin concatenationem (nominative concatenatio) "a linking together," noun of
action from past participle stem of concatenare "to link together," from com- "together" (see com-)
+ catenare, from catena "a chain" (see chain (n.)).
chain (n.)
c. 1300, from Old French chaeine "chain" (12c., Modern French chaîne), from Latin catena "chain"
(source also of Spanish cadena, Italian catena), which is of unknown origin, perhaps from PIE root
*kat- "to twist, twine" (source also of Latin cassis "hunting net, snare").
Figurative use from c. 1600. As a type of ornament worn about the neck, from late 14c. Chain of
stores is American English, 1846. Chain gang is from 1834;chain reaction is from 1916 in physics,
specific nuclear physics sense is from 1938; chain mail first recorded 1822, in Scott, from mail
(n.2). Before that,mail alone sufficed. Chain letter recorded from 1892; usually to raise money at
first; decried from the start as a nuisance.
Nine out of every ten givers are reluctant and unwilling, and are coerced into giving through the
awful fear of "breaking the chain," so that the spirit of charity is woefully absent. ["St. Nicholas"
magazine, vol. XXVI, April 1899]
Chain smoker is attested from 1886, originally of Bismarck (who smoked cigars), thus probably a loan- translation of German Kettenraucher. Chain-smoking is from 1930.
concatenate [con·cat·e·nate || kɒn'kætɪneɪt]
v. 如锁链般连续, 连结, 使连锁
more
1.作用:全屏方式分页显示文件内容
2.格式:more [选项] 文件名 ...
按Enter键向下逐行滚动
按空格键向下翻一屏
按q退出
Command | Action |
---|---|
PAGE UP or b | Scroll back one page. |
PAGE DOWN or Spacebar | Scroll forward one page. |
Up Arrow | Scroll up one line. |
Down Arrow | Scroll down one line. |
G | Move to the end of the text file. |
1G or g | Move to the beginning of the text file. |
/characters | Search forward to the next occurrence of characters. |
n | Search for the next occurrence of the previous search. |
h | Display help screen. |
q | Quit less. |
head: 查看文件开头的一部分(默认为10行)
tail:查看文件结尾的一部分内容(默认为10行)
格式:
head -n 文件名 ...
tail -n 文件名 ...
查看文件内容
配合“-f”选项使用时,还可以跟踪文件尾部内容的动态更新,便于实时监控文件内容的变化(Ctrl+C组合键终止)
统计文件内容——wc
1.作用:统计文件中单词数量(Word Count)等
2.命令格式:wc [选项]... 目标文件...
常用选项:
-l:统计行数
-w:统计单词个数
-c:统计字节数
检索和过滤文件内容——grep
1.作用:在文件中查找并显示包含指定字符串的行
2.命令格式:grep [选项]... 查找条件 目标文件
常用选项
-i:查找时忽略大小写
-v:反转查找,输出与条件不相符的行
3.查找条件设置
要查找的字符串以双引号括起来
"^......"表示以......开头,”......$”表示以......结尾
"^$"表示空行