linux命令下tailf 打开的文件怎么linux查找文件名命令命令

linux 命令怎么看文件数 find_百度知道
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。
linux 命令怎么看文件数 find
我有更好的答案
查看文件个数的话可以用这个命令find . -type f -print|wc -l
采纳率:61%
来自团队:
pre t="code" l="bash">find&*;f&-name&&.&-type&wc&nbsp.c&&|&nbsp
find -name &**& | wc -l
1条折叠回答
为您推荐:
其他类似问题
linux的相关知识
换一换
回答问题,赢新手礼包博客分类:
FROM:.cn/s/blog_6astet.html
功能:1)显示整个文件。如:$ cat filename
2)把文件串联接后传到基本输出,如将几个文件合并为一个文件或输出到屏幕。如:$ cat file1
file2 & file
参数详解:
-n或-number:由1开始对所有输出的行数编号,如:cat -n filename
-b或-number-nonblank:和-n相似,只不过对于空白行不编号
-s或-squeeze-blank:当遇到有连续两行以上的空白行,就代换为一行的空白行
-v或-show-nonprinting
cat -n file1 & file2:把file1的档案内容加上行号后输入file2这个档案里
cat -b file1 file2 && file3:把file1和file2的档案内容加上行号(空白行不加)后将内容附加到file3里
cat /dev/null & /etc/test.txt:清空/etc/test.txt档案内容
cat & filename:创建新文件
功能:以百分比的形式查看日志,类似cat,不过会以一页一页的显示方便使用者逐页阅读,按空白键(space)就往下一页显示,按b键(back)就会往回一页显示,而且还有搜寻字符串的功能(与vi相似),使用中的说明文件,请按h。退出按q。
参数详解:
-d:提示使用者,在画面下方显示[Press space to continue, 'q' to quit.],如果如果使用者按错键,则会显示 [Press 'h' for insuctions.] 而不是 '哔' 声 。
-s:当遇到有连续两行以上的空白行,就代换成一行的空白行。
+num:从第num行开始显示
more -s file:逐页显示file之档案内容,如有连续两行以上空白行则以一行空白行显示。
more +20 file:从第20行开始显示file之档案内容。
功能:less命令可以对文件或其他输出进行分页显示,与more命令相似。退出按q。
参数详解:
-a:在当前屏幕显示最后
-c:从顶部(从上到下)刷新屏幕,并显示文件内容。而不是通过底部滚动完成刷新;
-f:强制打开文件,二进制文件显示时,不提示警告;
-i:搜索时忽略大小写;除非搜索串中包含大写字母;
-I:搜索时忽略大小写,除非搜索串中包含小写字母;
-m:显示当前读取文件的百分比
-M:显示当前读取文件的百分比、行号及总行数;
-N:在每行前输出行号
-p pattern:搜索日志文件中含有pattern的所有日志内容;
-s:把连续多个空白行作为一个空白行显示
-Q:在终端下不响铃
g:跳到第一行
G:跳到最后一行
/pattern:搜索pattern
q:退出less
!command:调用SHELL,可以运行命令;比如!ls 显示当前列当前目录下的所有文件;
功能:从文本文件的头部开始查看,head命令用于查看一个文本文件的开头部分。
参数详解:
-n 制定您想要显示文本多少行
-n number 这个参数选项必须是十进制的整数,它将决定在文件中的位置,以字节单位。
-c number 这个参数选项必须是十进制的整数,它将决定在文件中的位置,以字节为单位。
head file.txt 显示file.txt的前十行内容;
head -n 20 file.txt 显示file.txt的前二十行内容;
功能:用于显示文本文件的末尾几行。
参数详解:
:从Number变量表示的512自己块位置开始读取制定文件。
:从Number变量表示的字节位置开始读取指定文件。
:tail -f 命令可用于监视另一个进程正在写入的文件的增长。
:从Number变量表示的1KB块位置开始读取制定文件。
:从Number变量表示的多字节字符位置开始读取指定文件。使用该标志提供在单字节和双字节字符代码集环境中的一致结果。
:从首行或末行位置来读取指定文件,位置由 Number 变量的符号(+ 或 - 或无)表示,并通过行号 Number 进行位移。
tail file.txt :显示文件file.txt的后十行内容。
tail -n 20 file.txt :显示文件file.txt的后二十行内容。
tail -f file.txt :显示文件file.txt的后十行内容并在文件内容增加后,自动显示新增的文件内容。
tail -n 50 -f file.txt :显示文件file.txt的后50行内容并在文件内容增加后,自动显示新增内容。
浏览: 329333 次
来自: 上海
CPU型号怎么弄?
你好,我需要FishermanJCE,请问能发份这个包给我么? ...
你好,我也需要这个例子的依赖的FishermanJCE相关的包 ...
json序列化反序列化插件-json2.js 介绍和使用 -
FishermanJCE 是山东渔翁公司加密卡提供调用加密机/ ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'tail命令可以将指定点到文件结束的内容写到标准输出。使用tail命令的-f选项可以方便的查阅正在改变的日志文件。tail -f filename会把filename里最尾部的内容显示在屏幕上,并且不断刷新,使你看到最新的文件内容。
-c Number |
-n Number |
-m Number |
-b Number |
-k Number ] [ File ]
常用的参数介绍
输出指定文件的最后十行,同时继续监视文件内容有无变化,新增内容会继续输出,直到按下 [Ctrl-C] 组合键停止该命令。
默认的tail -f 输出文件末尾10行的信息:
[root@localhost ~]# tail -f /var/log/nilex/clusterhead.log.4984256 Cleanup 0 closed sessions.6073024 No content(0) to be duplicated.3389248 [WARNING]: Failed to send cmd 399 to 192.168.14.14:9560.3389248 [ERROR]: [chnl_ctrl_pull_timeout] Failed to pull channel: -13.7085504 Start cleanup closed sessions.7085504 Cleanup 0 closed sessions.4984256 Start cleanup closed sessions.4984256 Cleanup 0 closed sessions.7085504 Start cleanup closed sessions.7085504 Cleanup 0 closed sessions
等效的命令:
[root@localhost ~]# tail --follow install.log.syslog&86&Feb 14 13:51:31 useradd[3050]: new group: name=xfs, GID=43&86&Feb 14 13:51:31 useradd[3050]: new user: name=xfs, UID=43, GID=43, home=/etc/X11/fs, shell=/sbin/nologin&86&Feb 14 13:51:39 useradd[3773]: new group: name=rpcuser, GID=29&86&Feb 14 13:51:39 useradd[3773]: new user: name=rpcuser, UID=29, GID=29, home=/var/lib/nfs, shell=/sbin/nologin&86&Feb 14 13:51:39 groupadd[3781]: new group: name=nfsnobody, GID=65534&86&Feb 14 13:51:39 useradd[3788]: new user: name=nfsnobody, UID=65534, GID=65534, home=/var/lib/nfs, shell=/sbin/nologin&86&Feb 14 13:51:47 useradd[3831]: new group: name=haldaemon, GID=68&86&Feb 14 13:51:47 useradd[3831]: new user: name=haldaemon, UID=68, GID=68, home=/, shell=/sbin/nologin&86&Feb 14 13:51:47 groupadd[3840]: new group: name=avahi-autoipd, GID=102&86&Feb 14 13:51:47 useradd[3845]: new user: name=avahi-autoipd, UID=100, GID=102, home=/var/lib/avahi-autoipd, shell=/sbin/nologin
从文件的末尾倒数Number行开始输出文件内容。
[root@localhost ~]# tail -n 10 install.log.syslog&86&Feb 14 13:51:31 useradd[3050]: new group: name=xfs, GID=43&86&Feb 14 13:51:31 useradd[3050]: new user: name=xfs, UID=43, GID=43, home=/etc/X11/fs, shell=/sbin/nologin&86&Feb 14 13:51:39 useradd[3773]: new group: name=rpcuser, GID=29&86&Feb 14 13:51:39 useradd[3773]: new user: name=rpcuser, UID=29, GID=29, home=/var/lib/nfs, shell=/sbin/nologin&86&Feb 14 13:51:39 groupadd[3781]: new group: name=nfsnobody, GID=65534&86&Feb 14 13:51:39 useradd[3788]: new user: name=nfsnobody, UID=65534, GID=65534, home=/var/lib/nfs, shell=/sbin/nologin&86&Feb 14 13:51:47 useradd[3831]: new group: name=haldaemon, GID=68&86&Feb 14 13:51:47 useradd[3831]: new user: name=haldaemon, UID=68, GID=68, home=/, shell=/sbin/nologin&86&Feb 14 13:51:47 groupadd[3840]: new group: name=avahi-autoipd, GID=102&86&Feb 14 13:51:47 useradd[3845]: new user: name=avahi-autoipd, UID=100, GID=102, home=/var/lib/avahi-autoipd, shell=/sbin/nologin
linux下的帮助文档:
[root@localhost ~]# man tail
tail – output the last part of files
tail [OPTION]… [FILE]…
DESCRIPTION
10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
–retry
keep trying to open a file even if it is inaccessible when tail starts or if it become use-ful when following by name, i.e., with –follow=name
-c, –bytes=N
output the last N bytes
-f, –follow[={name|descriptor}]
output appended da -f, –follow, and –follow=descriptor are equivalent
same as –follow=name –retry
-n, –lines=N
output the last N lines, instead of the last 10
–max-unchanged-stats=N
–follow=name,
FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files)
–pid=PID
with -f, terminate after process ID, PID dies
-q, –quiet, –silent
never output headers giving file names
-s, –sleep-interval=S
with -f, sleep for approximately S seconds (default 1.0) between iterations.
-v, –verbose
always output headers giving file names
–help display this help and exit
–version
output version information and exit
If the first character of N (the number of bytes or lines) is a ?(R)+??, print beginning with the Nth item from
otherwise,
in the file.
N may have a multiplier suffix: b 512, k 1024, m .
With –follow (-f), tail defaults to following the file descriptor, which means that even if a tail??ed file is renamed, tail
continue to track its end.
This default behavior is not desirable when you really want to track the actual name of the file, not the file descriptor (e.g., log rotation).
Use –follow=name in that case.
That causes
track the named file by reopening it periodically to see if it has been removed and recreated by some other program.
Written by Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering.
: //2167.html
电子邮件 *2011年5月 Linux/Unix社区大版内专家分月排行榜第一2011年4月 Linux/Unix社区大版内专家分月排行榜第一2011年3月 Linux/Unix社区大版内专家分月排行榜第一2010年12月 Linux/Unix社区大版内专家分月排行榜第一2010年11月 Linux/Unix社区大版内专家分月排行榜第一2010年10月 Linux/Unix社区大版内专家分月排行榜第一2010年9月 Linux/Unix社区大版内专家分月排行榜第一2010年8月 Linux/Unix社区大版内专家分月排行榜第一2010年7月 Linux/Unix社区大版内专家分月排行榜第一2010年6月 Linux/Unix社区大版内专家分月排行榜第一2010年5月 Linux/Unix社区大版内专家分月排行榜第一2010年4月 Linux/Unix社区大版内专家分月排行榜第一2010年3月 Linux/Unix社区大版内专家分月排行榜第一2010年2月 Linux/Unix社区大版内专家分月排行榜第一2010年1月 Linux/Unix社区大版内专家分月排行榜第一2009年10月 Linux/Unix社区大版内专家分月排行榜第一2009年9月 Linux/Unix社区大版内专家分月排行榜第一
2011年7月 Linux/Unix社区大版内专家分月排行榜第二2011年6月 Linux/Unix社区大版内专家分月排行榜第二2011年2月 Linux/Unix社区大版内专家分月排行榜第二
2012年11月 Linux/Unix社区大版内专家分月排行榜第二2011年8月 Linux/Unix社区大版内专家分月排行榜第二2008年10月 C/C++大版内专家分月排行榜第二
2012年8月 Linux/Unix社区大版内专家分月排行榜第三
2012年11月 Linux/Unix社区大版内专家分月排行榜第二2011年8月 Linux/Unix社区大版内专家分月排行榜第二2008年10月 C/C++大版内专家分月排行榜第二
2012年8月 Linux/Unix社区大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。博客分类:
我使用过的Linux命令之tail - 输出文件尾部/动态监视文件尾部
本文链接:
(转载请注明链接)
tail命令可以输出文件的尾部内容,默认情况下它显示文件的最后十行。它常用来动态监视文件的尾部内容的增长情况,比如用来监视日志文件的变化。与tail命令对应的是head命令,用来显示文件头部内容。
格式:tail file
输出指定文件file的尾部内容,默认输出最后十行内容(output the last part of files。Print
last 10 lines of each FILE to
standard output. )
格式:tail file1 file2 ...
指定多个文件时,会显示每个文件的文件名称,再显示该文件的尾部内容(With more than one FILE, precede each with a header
giving the file name.)
格式:tail
格式:tail -
不指定文件时,表明从标准输入读取内容,这通常用在管道线后面,把前一个命令的输出作为tail的输入内容(With no FILE, or when FILE is -, read standard
格式:tail -n
格式:tail -n n
格式:tail --lines=n
显示文件最后n
行,比如tail -20 file就是显示文件最后10行,这个参数可以配合其他参数与使用。注意上面三种格式的斜体n
是实际要显示的行数的数值。
注意:tail -n可以显示最后n行的文本内容。那么有没有一种方式显示从n行开始的文本内容,答案是肯定的。
tail -n +4 file表示显示文件file从第4行开始的内容。从1开始计数。
格式:tail -f file
动态跟踪文件file的增长情况(output appended data as the file grows),tail会每隔一秒去检查一下文件是否增加新的内容,如果增加就追加在原来的输出后面显示。但这种情况,必须保证在执行tail命令时,文件已经存在。
如果想终止tail -f的输出,按Ctrl+C中断tail程序即可。如果按Ctrl+C不能中断输出,那么可以在别的终端上执行killall tail强行终止。
注意:采用tail -f来监控文件变化情况时,在某些情况会不太灵。比如在java应用程序中采用log4j日志时,每隔1个小时生成一个新的日志文件,当前的日志输出在LOG4J.LOG中,当一个小时过去后,log4j会将LOG4J.LOG改名成LOG4J.yyyy-mm-dd-HH的形式。那么这个时候tail -f就不能动态输出新的日志内容了。tail命令本身提供了很多参数,似乎都不能完美的解决这个问题。最后只好编写了一个脚本ftail.sh来跟踪日志,详见《
》。刚才我仔细查看了tail的手册页,发现tail -F就能够做到跟踪这种类型的日志。转念一想,这种需求应该早就被Linux世界的人给满足了的。
格式:tail -F file
格式:tail --follow=name --retry file
功能与tail -f file相同,也是动态跟踪文件的变化,不同的是执行此命令时文件可以不存在。
以上处理都是针对文本文件的,下面是针对二进制文件的情形。
格式:tail -c n
取文件file的最后n个字节。
格式:tail -c +n
取文件file的第n个字节后的内容。从1开始计数。
示例一 输出文件尾部
先使用seq命令输出20个数字保存到1.txt,然后尝试使用tail命令。
[root@new55 ~]# seq 20 &1.txt
[root@new55 ~]# cat 1.txt
[root@new55 ~]# tail 1.txt
[root@new55 ~]# tail -3 1.txt
[root@new55 ~]# tail -n 3 1.txt
[root@new55 ~]# tail --lines=3 1.txt
[root@new55 ~]# tail -n +14 1.txt
[root@new55 ~]#
示例二 动态跟踪tomcat输出
动态跟踪tomcat输出。
[root@web logs]# tail -f catalina.out
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
13:23:02,236 [http-80-15] DEBUG mhr.roi.MhrManager - MhrGetJobReq={seq=991,job_id='6'}
13:23:02,301 [http-80-15] DEBUG mhr.roi.MhrManager - MhrGetJobRsp={seq=991,result=0(成功),,info={job_id='6',employer_id=,employer_name=无锡富士时装有限公司,,,job_title='|570309|',job_title0='文员',job_type=f(全职),issue_time=' 00:00:00.0',work_address='1902',work_address0=无锡市,desired_count='1',,,,,,job_desc=大专,1年以上5s管理工作经验,电脑操作熟练。,required_experience=1(一年以上),,,,required_degree=15(大专),,,,,,,valid_days=30,access_count=12,expire_time=' 00:00:00.0',job_status=1(过期),,,,,,contact_name=王小姐,contact_number=8,remarks='★此职位是从后台导入的
',enter_time=' 09:45:11.0',change_time= 02:18:05.0,,job_seq=123201,,required_min_age=22,,,accommodations=面议,serve_principal=wjw12580,job_summary=大专,1年以上5s管理工作经验,电脑操作熟练,,}}
13:23:02,302 [http-80-15] DEBUG mhr.roi.MhrManager - MhrGetEmployerReq={seq=0,employer_id=''}
13:23:02,304 [http-80-15] DEBUG mhr.roi.MhrManager - MhrGetEmployerRsp={seq=0,result=0(成功),,info={employer_id='',employer_name=无锡富士时装有限公司,employer_region=1902,employer_address=无锡市滨湖镇山水城科技园8号,,employer_desc=无锡富士时装(集团)有限公司成立于1992年,是中日韩合资企业。主要生产高档针织时装,产品全部外销,连续多年荣获“中国行业500强”、“全国工业重点行业效益十佳企业”、“无锡市百佳企业”等称号。公司总部位于江苏省无锡市滨湖镇山水城科技园,全新的厂房设施,占地面积30亩。公司分别在苏州、泰兴、盐城、徐州设有分厂,集团公司现有职工1500多人,年销售额近3亿元。,,,,,,open_mode=5(系统自动操作),open_time=' 09:45:10.0',,,,,contact_name=王小姐,contact_number=8,,,,,employer_status=1(已经开通),,,login_password=871386,,agency=false,balance=100.0000,,,,,serve_principal=wjw12580,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,remarks='此帐号由“12580zgz-盐城维克多网络传媒有限公司”导入',enter_time=' 09:45:10.0',}}Ctrl+C
[root@web logs]#
示例三 动态跟踪log4j日志
经过我的试验,发现tail -F功能的强大,它等同于--follow=name --retry。如果你跟踪的文件被移动或者改名后, 你还想继续tail它, 你可以使用这个选项。
tail手册页中关于--retry的说明:keep trying to open a file even if it is inaccessible when tail starts or
becomes useful when following by name, i.e., with --follow=name。
tail命令开始执行时文件不存在或者执行过程中文件不能访问,会不断重试。
关于--follow的说明:-f, --follow[={name|descriptor}] output appended da -f, --follow, and --follow=descriptor are equivalent
。--follow=descriptor表明跟踪的是文件描述符,
--follow=name表明跟踪的是文件名称。
如果文件名称改掉之后,还想继续跟踪原文件名称对应的尾部内容,就得使用-F选项而不是-f选项了。
[root@web imx_server]# tail -F log/IMX.LOG
14:13:28.892
INFO ImxConnection[6] imx.server.ImxConnection - RX IMX_ACTIVE_TEST{seq=3460,client_id=9042,presence_status=1(presence_status_online),}
14:13:28.892 DEBUG ImxConnection[6] org.logicalcobwebs.proxool.ImxDB - /02/00) - Connection #9 served
14:13:28.892
INFO ImxConnection[6] imx.dbo.ImxOnlineInfoRow - EXEC SQL UPDATE imx_online_info SET last_active_time = ' 14:13:28.0' WHERE account = 'zhy'
14:13:28.894 DEBUG ImxConnection[6] org.logicalcobwebs.proxool.ImxDB - UPDATE imx_online_info SET last_active_time = ' 14:13:28.0' WHERE account = 'zhy';
(1 milliseconds)
14:13:28.894 DEBUG ImxConnection[6] org.logicalcobwebs.proxool.ImxDB - /02/00) - Connection #9 returned (now AVAILABLE)
14:13:29.625
INFO ImxConnection[6] imx.server.ImxConnection - RX IMX_ACTIVE_TEST{seq=3461,client_id=9042,presence_status=1(presence_status_online),}
14:13:29.626 DEBUG ImxConnection[6] org.logicalcobwebs.proxool.ImxDB - /02/00) - Connection #8 served
14:13:29.626
INFO ImxConnection[6] imx.dbo.ImxOnlineInfoRow - EXEC SQL UPDATE imx_online_info SET last_active_time = ' 14:13:29.0' WHERE account = 'zhy'
14:13:29.627 DEBUG ImxConnection[6] org.logicalcobwebs.proxool.ImxDB - UPDATE imx_online_info SET last_active_time = ' 14:13:29.0' WHERE account = 'zhy';
(0 milliseconds)
14:13:29.653 DEBUG ImxConnection[6] org.logicalcobwebs.proxool.ImxDB - /02/00) - Connection #8 returned (now AVAILABLE)Ctrl+C
[root@web imx_server]#
总结一下:要想跟踪会更名的日志的话,用tail -F而不是tail -f。
示例四 处理二进制文件
[root@new55 ~]# seq 20 &1.txt
[root@new55 ~]# cat 1.txt
[root@new55 ~]# hexdump -C 1.txt
0a 32 0a 33 0a 34 0a
35 0a 36 0a 37 0a 38 0a
|1.2.3.4.5.6.7.8.|
0a 31 30 0a 31 31 0a
31 32 0a 31 33 0a 31 34
|9.10.11.12.13.14|
a 31 35 0a 31 36 0a 31
37 0a 31 38 0a 31 39 0a
|.15.16.17.18.19.|
[root@new55 ~]# tail -c 10 1.txt | hexdump -C
a 31 38 0a 31 39 0a 32
|.18.19.20.|
[root@new55 ~]# tail -c -10 1.txt | hexdump -C
a 31 38 0a 31 39 0a 32
|.18.19.20.|
[root@new55 ~]# tail -c +10 1.txt | hexdump -C
a 36 0a 37 0a 38 0a 39
0a 31 30 0a 31 31 0a 31
|.6.7.8.9.10.11.1|
0a 31 33 0a 31 34 0a
31 35 0a 31 36 0a 31 37
|2.13.14.15.16.17|
a 31 38 0a 31 39 0a 32
|.18.19.20.|
[root@new55 ~]#
【1】Linux宝库
【2】Tai的日记
【3】CSDN论坛
【4】短裤党
【5】新课网
浏览 56432
codingstandards
浏览: 3365232 次
来自: 上海
如果有A进程原代码情况下,通过如下调用,把他的子进程继承关闭则 ...
楼主咋没分析下源码呢?
tail -F 就可以吧
新手学习了,就是不明白为一个网卡配多个ip有什么用
不错,谢谢!
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'

我要回帖

更多关于 linux下查找文件命令 的文章

 

随机推荐