由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - 向高人请教:怎么从大量的文件中grep
相关主题
how to grep a string in all sub-dirs?请教一个shell script的问题
my script Re: how would you do this?请教:有关位置参数的问题。
Shell script求教简单问题,可我不会。:( 急用啊!
如何删除一组文件或给一组文件更名?新手unix shell script debugging help!
太多文件不能用 ls * OR mv * ? 如何判定一个文件下载已经结束?
[转载] qestion about grep如何把一个目录下的文件名全部改成小写?
有关Unix shell script的问题[转载] How to list the files with specific permission?
Help on shell scriptHow FTP the whole Dir(include Subdir) in UNIX?
相关话题的讨论汇总
话题: grep话题: 文件话题: error话题: xargs话题: arguments
进入Unix版参与讨论
1 (共1页)
n**r
发帖数: 183
1
Hi,
Any one know how to use grep. I got the following error:
Arguments too long
I do some research on this issue. Some one said I can use xargs. The I try:
find . -type f |xargs grep "Run_Time" *
I get the error again.
各位高人可有什么建议?我知道文件的数目很大。不知谁有写过scripts.
或者用其他方法。比如怎么按文件生成的时间来查。先grep今天生成的文件,在grep昨
天生成的文件。
先谢了。
w*m
发帖数: 1806
2
Here is my favorite grep command,
maybe you can modify it,
find .-name '*' -exec grep "Run_Time" {} \; -print
I think you can change -name to -type

【在 n**r 的大作中提到】
: Hi,
: Any one know how to use grep. I got the following error:
: Arguments too long
: I do some research on this issue. Some one said I can use xargs. The I try:
: find . -type f |xargs grep "Run_Time" *
: I get the error again.
: 各位高人可有什么建议?我知道文件的数目很大。不知谁有写过scripts.
: 或者用其他方法。比如怎么按文件生成的时间来查。先grep今天生成的文件,在grep昨
: 天生成的文件。
: 先谢了。

n**r
发帖数: 183
3
I try your suggestion, but I got the "Arguments too long" Error.
Thank you any way. This is a good idea.
j******y
发帖数: 700
4
"Arguments too long" Error means your file list is too big for find to
handle. Try to use perl, here's how:
perl -e 'opendir(DIR, "."); @all = grep //, readdir DIR; closedir
DIR; for (@all) { do something }'
r*****z
发帖数: 906
5
你没用对xargs,建议看看它的man先
这个问题来自于你给shell的通配符*,是它被shell展开后过长造成的,
而xargs其实就是用来避免shell掺和

【在 n**r 的大作中提到】
: Hi,
: Any one know how to use grep. I got the following error:
: Arguments too long
: I do some research on this issue. Some one said I can use xargs. The I try:
: find . -type f |xargs grep "Run_Time" *
: I get the error again.
: 各位高人可有什么建议?我知道文件的数目很大。不知谁有写过scripts.
: 或者用其他方法。比如怎么按文件生成的时间来查。先grep今天生成的文件,在grep昨
: 天生成的文件。
: 先谢了。

v*****r
发帖数: 1119
6
楼上说的对,应把 ‘*' 从 grep 里去掉,不然即使不报 'argument too long'的错,
返回的结果都是 duplicate 的 (因为 grep 了两遍)

【在 r*****z 的大作中提到】
: 你没用对xargs,建议看看它的man先
: 这个问题来自于你给shell的通配符*,是它被shell展开后过长造成的,
: 而xargs其实就是用来避免shell掺和

1 (共1页)
进入Unix版参与讨论
相关主题
How FTP the whole Dir(include Subdir) in UNIX?太多文件不能用 ls * OR mv * ?
shell programming problems[转载] qestion about grep
How do i get a list of all computers?有关Unix shell script的问题
replace a string in all files under a directory?Help on shell script
how to grep a string in all sub-dirs?请教一个shell script的问题
my script Re: how would you do this?请教:有关位置参数的问题。
Shell script求教简单问题,可我不会。:( 急用啊!
如何删除一组文件或给一组文件更名?新手unix shell script debugging help!
相关话题的讨论汇总
话题: grep话题: 文件话题: error话题: xargs话题: arguments