由买买提看人间百态

topics

全部话题 - 话题: grep
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
r*****r
发帖数: 397
1
I have a directory with hundreds of *.doc files,and I want to search a word "t
otal", if the total value is greater than 50, then I want to copy this file to
a new directory,and change the name sequentially to file001.doc,file002.doc .
...sth like that.
So, when I grep "total" ,I got
file1.doc
total: 12
file2.doc
total: 13
file3.doc
total: 56
...
#! /bin/tcsh
foreach wordfile (*.doc)
grep total $wordfile | awk '($2 > 50) {com = sprintf("cp " $wordfile "
../new_dir");print c
p********b
发帖数: 7
2
来自主题: Programming版 - Shell script 问题
I think i know what you want this time
First you need to let do-it runnig at back ground and redirect output to
another file. Then trace that file till you find what you are looking for
and kill do-it
the shell script should look like this:
do-it &> output.txt &
while [-e ./output.txt]
do
tail output.txt | grep "PATTERN" | xargs ./check.sh
done
in check.sh :
if [-n $1] ## check whether $1 is empty
then
ps auxww | grep "do-it" | awk {"print $2"} | xargs kill -9 ##kill do-it
mv output.txt
h**o
发帖数: 548
3
来自主题: Programming版 - how to count the times a function is used
But I do not know what function appear in this files.
I only know there are some format which I can use to parse the names of
these function (see the attachment in the previous response)
I think I can first use grep to parse these function name, then count them
using for, sort,etc.
But I do not know how to grep them.
v*s
发帖数: 946
4
来自主题: Programming版 - 什么是UNIX sed的holding buffer
好像就是一个内部的 buffer,可以临时放点东西而已。
这个grep3 其实基本的grep就能实现。
grep -A 1 -B 1 "pattern"
z********0
发帖数: 9013
5
来自主题: Programming版 - 问问g++, gcc, cc之间的关系
normally, cc is gcc
gcc uses C frontend
g++ uses C++ frontend
gcc -c -S a.c -v 2>&1 |grep cc1
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/cc1 -quiet -v a.c -quiet -
dumpbase a.c -mtune=generic -march=x86-64 -auxbase a -version -o a.s
g++ -c -S a.c -v 2>&1 |grep cc1
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/cc1plus -quiet -v -D_GNU_SOURCE
a.c -quiet -dumpbase a.c -mtune=generic -march=x86-64 -auxbase a -version -
o a.s
w***g
发帖数: 5958
6
受教了,grep版本为
grep -P -o '(?<="id":)[0-9]+'
j********x
发帖数: 2330
7
来自主题: Programming版 - 还是awk牛B
怎么总是有人提这种cat xxx | grep/awk/sed ...
直接grep awk sed ...
莫名其妙。。。
n******7
发帖数: 12463
8
来自主题: Programming版 - 正则表达式里括号的转义好乱
grep/vim/perl等的正则语法都有些不同
所以没必要不要折腾这个,用一种就好
比如grep 可以用-P
不然会精分
f********x
发帖数: 99
9
Spark采用batch engine来处理数据; Flink采用stream engine处理数据。
Spark的streaming process = micro batch; Flink的batch process = streaming
process的特殊情况。
在现实世界里,大数据平台处理数据的过程就好比油罐车拉原油的过程。你可以调用油
罐车队批量拉油(spark micro batch),也修建石油管道直接输送原油(Flink
streaming)。
在计算机领域里,两个大数据平台的本质其是源于对Unix Pipes在分布式环境下的演化
。 下面用Linux自带的工具举个例子,来比较一下Spark和Flink的不同点。假设我们想
统计FileA里面的关键字China的总数:
Spark的处理模式可以等效为: cat FileA > /dev/shm/RDD1; grep China /dev/shm/
RDD1 > /dev/shm/RDD2; wc -l /dev/shm/RDD2 > /dev/shm/FileB
Flink的处理模式可以等效为: cat File... 阅读全帖
c*********e
发帖数: 16335
10
来自主题: Programming版 - 讲一个单进程死锁
grep -i keyword -R .
或者
grep -i keyword -R . >> output.txt
有问题吗?
b*******s
发帖数: 5216
11
来自主题: Programming版 - 讲一个单进程死锁
alias GREP='grep -R --exclude="tags" --include="*.cpp" --include="*.h" --
include="*.c" --include="*.py"'
copied from my .bashrc
g****e
发帖数: 172
12
【 以下文字转载自 Linux 讨论区 】
发信人: gangle (nothing), 信区: Linux
标 题: 请高手帮忙看看这个chkrootkit安全否?
发信站: BBS 未名空间站 (Mon Aug 13 18:29:14 2012, 美东)
那些suspicious files安全吗?
多谢!!
sudo chkrootkit
ROOTDIR is `/'
Checking `amd'... not found
Checking `basename'... not infected
Checking `biff'... not found
Checking `chfn'... not infected
Checking `chsh'... ... 阅读全帖
L***n
发帖数: 6727
13
来自主题: Software版 - 终于打算买一个常用软件了
win grep有啥不好么? 不过我一般直接用grep
n*w
发帖数: 3393
14
为了grep,或者grep pdf的工具也行。
c**t
发帖数: 2744
15
来自主题: Unix版 - sed? awk? or mak a program?
ps -aef | grep cogt
cogt 6998 6284 0 13:51:41 pts/38 0:00 server
cogt 6284 6281 0 13:28:04 pts/38 0:00 -ksh
cogt 7071 6284 0 13:53:46 pts/38 0:00 server 20089
cogt 7500 6284 0 14:06:40 pts/38 0:00 grep cogt
~
~
I try to kill -9 6998 7071.

What commandline can do this?
sed? awk? or make a program?
p*a
发帖数: 592
16
来自主题: Unix版 - sed? awk? or mak a program?
ps -aef | grep cogt | grep server | awk '{print $2}' | xargs -i kill -9 {}
i**********r
发帖数: 36
17
I have a command working in the interactive mode
$tcsh -f -c "cd ~/HowTo/;grep -e '^Q:' *.QA"
now I want to make an alias like
alias listht tcsh -f -c "cd ~/HowTo/;grep -e '^Q:' *.QA"
but obviously it won't work, since tcsh will strip the "s.
though in this particular case I can omit the inner ' and use ' to escape ",
but sometimes you need to escape both, then how can you do that?
thanks!
l******o
发帖数: 25
18
I have stolen a ucbcc from the central sever of our
university.
now. there is still a problem of the cc.
it complains it can not call /usr/ccs/bin/acomp.
what does acomp for?
also, how can I search a file with find and grep?
it should be like " find /usr -name "acomp" | grep .... etc?
right?
thanks a lot.
m*****e
发帖数: 4193
19
1. which grep are you using? You should use GNU grep or egrep.
2. make sure your lines do not end with '\r\n' like most files
edited under DOS
F***Q
发帖数: 6599
20
I use AIX 4.3
both grep and egrep give me the first line of the file when
i use
?grep '\n' myfile
but can't find all of the lines,also,the specified line I
am searching
sed even dosen't accept '\n':(
bz
发帖数: 1770
21
来自主题: Unix版 - 一个高技术问题
use
grep "atoi" *
instead of
cat *|grep "atoi"
v*****s
发帖数: 10
22
来自主题: Unix版 - 一个高技术问题
grep -H atoi *
grep -l atoi *
d****i
发帖数: 4354
23
来自主题: Unix版 - 想写个小东东
看大堆代码的时候,为了把各部分内容联系起来,经常用grep去查一个词在哪里
出现,我想写个比grep功能强的小程序帮助代码分析,可以区分function declaration
和function implementation和调用,变量属哪个类等等,unix/linux有这样的小工具吗?
kb
发帖数: 73
24
来自主题: Unix版 - 太多文件不能用 ls * OR mv * ?
use pipe and grep.
Like ls | grep "AN"
T********r
发帖数: 6210
25
来自主题: Unix版 - 再问一个关于Telnet的问题
don't give up so quickly. you can still try rlogin/rsh
grep rlogin /etc/inetd.conf
grep rsh /etc/inetd.conf
or
telnet localhost 512
telnet localhost 513
to see if these services are open.
or if you are root, try to copy an in.telnetd from other Solaris
7 machines.
a*******s
发帖数: 324
26
来自主题: Unix版 - 请问几个关于Sed的问题
I use tcsh.

sed -e /[0-9]/d filename
don't know how to just use only line to do it.
don't know how to just use only line to do it.
I don't know how to easily express non-capital alphabetical character
in "sed".
Is "grep" acceptable?
grep "^[A-Z]" filename
f****a
发帖数: 28
27
来自主题: Unix版 - SunOS下的中文。
呵呵,那只是一个中文terminal啦。
我需要的是在CDE任意窗口下能正常显示中文的方法:(
其实,我用的是x-win32远程登陆到学校的sun server的。
刚才google了一下,下载了一个far east的中文支持包,号称是只要在x-win32的
font里加上它就可以了,试了试,不成:(
在server的/usr/openwin/lib/font/locale/里面没有发现zh目录;
运行了xlsfonts -display mypc.ip:0 | grep gb2312;
系统信息:
wangz-2-% xlsfonts -display 139.13.209.183:0 | grep gb2312
-isas-fangsong ti-medium-r-normal--0-0-72-72-c-0-gb2312.1980-0
-isas-fangsong ti-medium-r-normal--16-160-72-72-c-160-gb2312.1980-0
-isas-song ti-medium-r-normal--0-0-72-72-c-0-gb2312.1980-
m***z
发帖数: 1
28
来自主题: Unix版 - how to search a pattern in all files

Shell script:
% grep "your_pattern" * -R
Similarly in perl:
system ('grep', 'your_pattern', '.' ,'-R')
should work.
a****a
发帖数: 98
29
来自主题: Unix版 - how to search a pattern in all files
grep -r
otherwise, update your grep
l*****i
发帖数: 3929
30
来自主题: Unix版 - [转载] 问个小问题
【 以下文字转载自 Linux 讨论区 】
【 原文由 longhei 所发表 】
我有一些程序,需要找出里面所有的“\”符号,但是用“grep \ *”不行。如何才
能用grep达到这一目的呢?
thanks!
t******q
发帖数: 117
31
#!/bin/bas
#assum all programs are under your current dir. all executable
progset = `ls -l`
for prog in $progset;
do
./$prog&;
sleep 900;
ps aux | grep $prog | gawk '{print $2}' >> prog.log
ps aux | grep $prog | gawk '{print $2}' | xargs kill
done



c*****t
发帖数: 1879
32
你还是 man ps 一下看看。ps 一般只是列下执行 ps 的 shell 里的程序。
你必须加些 parameter 才查找所有的程序。比如
ps -elf | grep emacs | grep username
(有些机器上是 ps aux,linux 是两者皆可)。
D****e
发帖数: 9
33
来自主题: Unix版 - 问两个问题
1) netstat -antp | grep `ps -eaf | grep test | awk '{print $2}' | head -n
1`
or use lsof to list out the fd
2) man swapon
m****n
发帖数: 1066
34
来自主题: Biology版 - A question about R language.
> genes<- c("ACTB","LACTB", "ACTBCC", "AC-TB", "ACTB$")
> grep("ACTB", genes)
[1] 1 2 3 5
> grep("^ACTB$", genes)
[1] 1
u*********1
发帖数: 2518
35
作为一个曾经0基础的菜鸟,我还是蛮有体会的。
想想一年前我连linux里的grep都不晓得是啥。老板说“grep”,我说gre。。啥?greb
吗?老板摇摇头说you really have a lot to learn...不过老板超好,想办法给我把
各种基础的东西讲清楚。。。包括RAM是啥。。汗。。。
做NGS/bioinformatics的,我觉得核心思想还是:如何利用计算机手段解决生物问题。
说起来简单但未必每个人都深刻体会的到。什么python/bash/perl啥啥的,要入门很快
,但也绝对不是什么两个星期就搞定。我现在和python打交道也一年了,但也完全就是
个皮毛,主要是你自己的project决定的。。如果你永远只需要简单的process下你的
text,而且text如果不大比如100MB,你可以永远for line in text。。或者readlines
(),但如果碰到很大的text,就不能readlines()了因为cluster可能没有那么大的
memory to load the whole text.
所以我觉得就是现学现用,除非你是CS系科班搞计算出身... 阅读全帖
c****w
发帖数: 79
36
来自主题: Quant版 - 又一个码题
nobody cares?
here is an ugly one,
assume the text file is a, then
$ nl -w10 -n rz a | grep mouse > a0
$ nl -w10 -n rz a | grep -v mouse > a1
$ cat a1 | sed 's/cat/dog/g' > a11
$ cat a11 a0 | sort | sed 's/[0-9]*\t//' > b
then file b has the result
c****w
发帖数: 79
37
来自主题: Quant版 - 又一个码题
there were errors, so here's a better ugly one, hehe
$ nl -n rz a | grep mouse > a0
$ nl -n rz a | grep -v mouse | sed 's/cat/dog/g'> a1
$ cat a1 a0 | sort | sed 's/^[0-9]*\t//' > b
g**********t
发帖数: 475
38
来自主题: Statistics版 - 大牛帮忙:批处理读入多个文件!!
#!/usr/bin/perl -w
use strict;
opendir DIR, "./" or die "$!\n";
for (grep {m/^RC_/} readdir DIR){
open IN, $_ or die "$1\n";
open OUT, ">C_$_" or die "$!\n";
print OUT (join (",", grep {$_} map {$1 if /^\s*([^\s]+)\s+Numeric/} <
IN>), "\n");
close IN;
open IN, "D_$_" or die "$!\n";
print OUT ;
close IN;
close OUT;
}
代码保存为.pl文件放到数据文件夹下直接运行即可
l*******s
发帖数: 7316
39
由下面帖子的方法改编,加上本人的刷机体会。
https://slickdeals.net/forums/showpost.php?p=92529215&postcount=2163
小白可以先看一下这个科普,对下面的步骤可以理解更好一些
http://www.mitbbs.com/article_t/PDA/32957337.html
Step 0:电脑上需要的两个软件:
WinSCP
https://winscp.net/download/WinSCP-5.9.3-Setup.exe
Putty (如果有其他SSH软件,可以不装)
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Step 1:下载5个文件:
cfe.exe. (如果用公孙的在线修改,可以不下载这个文件
http://www.mitbbs.com/article_t/PDA/32960375.html
https://mega.nz/#!9kZjGS6C!tTOddFCpoJNgobda4efk-5rN6m96m1u8ouCshw0qx-... 阅读全帖
A*********t
发帖数: 7481
40
来自主题: _DC版 - 光荣榜
#cat "光荣榜"|grep -v crazyrabbit |grep -v alligator
alligator
crazyrabbit
#why?
command not found
S*********g
发帖数: 24893
41
【 以下文字转载自 WaterWorld 讨论区 】
发信人: LouderYeah (Louder Yeah), 信区: WaterWorld
标 题: 韩《三*门》涉及到全部书籍以及外文
发信站: BBS 未名空间站 (Thu Feb 9 04:07:05 2012, 美东)
linux grep结果:
(已经remove duplicates,并按出现次数排名)
可见原作者精读《史记》,《红楼梦》,《肉蒲团》等古籍。
这些只是加书名号的
没有加书名号的引用典籍还有很多
这里没有录入
---------------------------------------------------
出现顺序 书名 出现次数
(第x个citations)
----------------+----------------------+-----------
134 《初露》 12
34 《史记》 10
99 ... 阅读全帖
u**x
发帖数: 45
42
来自主题: History版 - 祖宗们不能灌水怎么办?
门前不扫, 苍蝇来找。前面没我的RE大该给憋了很久的人看到了希望了。
上次look说到,(大概是), 汉语里没主格宾格区别,可以互换。 我说有,
比如“吾”在古代就是主要作主格用的, 很少作宾格, 偶尔作宾格, 但要倒装,
比如, “天下不吾知”。(说实话,我倒不记得这个例子了, 不过没关系)
我没看出这和否定句的代词宾语前置有矛盾。 这个例子很合我的意思, 在上古
的语法里正是这样倒装使得吾作宾语半合法话了。 不吾知, 不吾见, 是比较
而言较常见的”吾“作宾语的情形。 倒是我觉得你对语法有些概念上的错误,
语法不是为语法而语法的。语法与其说是言语的原因或目的不如说是言语的现象。
不是说这里是“为了”否定句, “为了”代词作宾语要倒装, 好象为了这个,
就不是为了吾倒装。这两个都不是原因目的,是现象。 吾作宾语在否定的倒
装句中比较常见(比较而言〕。
我记得我还举了个庄子里”吾丧我“的例子。 你大该是搜索了一下, 找出了
一个”抚汝指吾”, 估计是在古文观止了找出来的。 我上次就建议你作个实
验, 用grep or whatever you prefer, egrep  我)||(吾
g**8
发帖数: 4951
43
来自主题: Military版 - 中國貿易 3月上旬持續逆差
谢谢楼主发贴提醒大家。
也再次容我在这里议论:中国对具体个别外国的贸易逆差被政府媒体和公众一再高调华丽的忽视,是非常严重的问题。具体地说:中国对南韩外贸逆差连年持续走高,政府媒体公众不但毫无关注,甚至刻意淡化和在新闻中完全回避不报! 实在不明白到底是什么用意。现在中国对外贸易整体逆差都要出现了,如果再不引起重视,实在不知有何大棋要展开。
这里是我刚刚在海关总署网站上看到他们定期发布的统计数字,大家可以自己查实确认:
http://www.customs.gov.cn/publish/portal0/tab2453/module72494/i
截止目前他们发布的详细统计数据还只限至1月底的单月统计,而根据中国统计中国对南韩外贸逆差还是最大的国别逆差,达到65.6亿,第二位的对日逆差则才有47.1亿美元,中国对南韩逆差比对日逆差多了百分之40%。 依照这个平均单月统计,全年就会是接近800亿美元的对韩逆差。而年中特别是年末更会是比一二月春节前后的淡季要更猛。
我实在不明白,中国政府媒体公众,有真的精英吗?
再次列上我的前述帖子:
http://www.mitbbs.com/article/... 阅读全帖
r*****n
发帖数: 4844
44
前言
你是否觉得自己从学校毕业的时候只做过小玩具一样的程序?走入职场后哪怕没有什么
经验也可以把以下这些课外练习走一遍(朋友的抱怨:学校课程总是从理论出发,作业
项目都看不出有什么实际作用,不如从工作中的需求出发)
建议:
不要乱买书,不要乱追新技术新名词,基础的东西经过很长时间积累而且还会在未来至
少10年通用。
回顾一下历史,看看历史上时间线上技术的发展,你才能明白明天会是什么样。
一定要动手,例子不管多么简单,建议至少自己手敲一遍看看是否理解了里头的细枝末
节。
一定要学会思考,思考为什么要这样,而不是那样。还要举一反三地思考。
注:你也许会很奇怪为什么下面的东西很偏Unix/Linux,这是因为我觉得Windows下的
编程可能会在未来很没有前途,原因如下:
现在的用户界面几乎被两个东西主宰了,1)Web,2)移动设备iOS或Android。Windows
的图形界面不吃香了。
越来越多的企业在用成本低性能高的Linux和各种开源技术来构架其系统,Windows的成
本太高了。
微软的东西变得太快了,很不持久,他们完全是在玩弄程序员。详情参见《Windows编
程革命史》
所以... 阅读全帖
xt
发帖数: 17532
45
是啊,现在民主美国已经把grep上网了。
b***y
发帖数: 14281
46
哪有什么牛叉软件,回复全部下载成文本文件,然后用DOS小trick搜索一下关键词,类
似Unix的cat grep cut。

★ 发自iPhone App: ChineseWeb 7.7
v*x
发帖数: 1370
47
估计和贝志城的神马软件一点关系都木有。就是usenet遇上几个大牛讨论起来,N个回
合以后人家逐渐统一到铊中毒,最后有84个都同意。那么贝公子呢,就只能傻看人家热
烈讨论不得要领。终于有大牛激动的写了三遍大写的铊,这回贝傻子终于抓住了稻草,
急忙找来众人,一个个回复邮件的数。师哥蔡烦了,写了个cat * | grep之类的,贝看
傻了,如获至宝拿去找协和了。
l***y
发帖数: 4671
48
问题是小贝咋知道要用 Thallium 来当关键字?
另外,你这个命令得不出建议是铊中毒的 email 的数量。两个原因:一封 email 里有
可能 Thallium 出现在多行;回别人 email 时 cite 原文,而原文中有 Thallium。
最后,你已经 cat emails 了,为什么还要搞个循环?
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)