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掺和
|