[root@localhost /root]#grep –f wuxy /etc/passwd
【例】在/home/wuxy 目录和子目录下的所有文件中查找字符串“print”出现的次数。 [root@localhost /root]#grep –r 'print' /home/wuxy wc 命令 一般格式: wc [选项] 文件列表
该命令统计出指定文件的字节数、字数、行数,并输出结果。如果没有给出文件名,则从标准输入读取数据。如果多个文件一起进行统计,则最后给出所有指定文件的总统计数。
wc 命令输出列的顺序和数目不受选项顺序和数目的影响,输出格式如下: 行数 字数字节数文件名
选项及其含义如下。 -c:统计字节数。 -l:统计行数。 -w:统计字数。
【例】统计文件m1.c 和m3.c 的字节数、字数和行数。 [root@localhost /root]#wc -lcw m1.c m3.c 7 8 63 m1.c 4 4 30 m3.c cat 命令
cat 命令连接文件并打印到标准输出设备上。cat 经常用来显示文件的内容,相当于cat 命令的一般格式: cat [选项] 文件名1 [文件名2]
DOS下的type 命令。 该命令有两项功能,其一是用来显示文件的内容。它依次读取由参数文件1 所指明的文件,将它们的内容输出到标准输出上。其二是连接两个或多个文件,如cat f1 f2 >f3,将把文件f1 和f2 的内容合并起来,然后通过输出重定向符“>”,将它们的放入文件f3 中。 选项的含义如下。
-b,--number -noblank:从1 开始对所有非空输出行进行编号。 -n,--number:从1 开始对所有输出行编号。
-s,--squeeze-blank:将多个相邻的空行合并成一个空行。
注意:当文件较大时,文本在屏幕上迅速闪过,用户往往看不清所显示的内容。 【例】在系统中有clear.txt 文件,其内容如下: clear(1) clear(1) NAME
clear - clear the terminal screen SYNOPSIS
clear
DESCRIPTION
clear clears your screen if this is possible. It looks in the environment for the terminal type and then in the terminfo database to figure out how to clear the screen. SEE ALSO tput(1), terminfo(5) clear(1)
用cat 命令显示clear.txt 文件内容。 [root@localhost/root]$cat clear.txt clear(1) clear(1) NAME
clear - clear the terminal screen
SYNOPSIS clear
DESCRIPTION
clear clears your screen if this is possible. It looks in the environment for the terminal type and then in the terminfo database to figure out how to clear the screen. SEE ALSO tput(1), terminfo(5) clear(1)
【例】在系统中有cd.txt 文件,其内容如下: BASH_BUILTINS(1) BASH_BUILTINS(1) NAME
bash, :, ., [, alias, bg, bind, break, builtin, cd, command,