免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 2422 | 回复: 11
打印 上一主题 下一主题

在linux中怎样在一个文档中查找一个字符串呢? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-01-28 16:14 |只看该作者 |倒序浏览
在linux中怎样在一个文档中查找一个字符串呢?
谢谢!

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
2 [报告]
发表于 2005-01-28 16:25 |只看该作者

在linux中怎样在一个文档中查找一个字符串呢?

grep,sed,awk,均可
RE:
\<string\>;

论坛徽章:
0
3 [报告]
发表于 2005-01-28 16:30 |只看该作者

在linux中怎样在一个文档中查找一个字符串呢?

楼上你好?
我是一新手有很多东西还不知道,
如果我要查找文件:greip.c 中字符top20
并把top20改为top100 ,
应该怎样做呢?
谢谢!

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
4 [报告]
发表于 2005-01-28 16:42 |只看该作者

在linux中怎样在一个文档中查找一个字符串呢?

原帖由 "congcn" 发表:
楼上你好?
我是一新手有很多东西还不知道,
如果我要查找文件:greip.c 中字符top20
并把top20改为top100 ,
应该怎样做呢?
谢谢!

  1. sed -i 's/top20/top100/g' greip.c
复制代码

论坛徽章:
0
5 [报告]
发表于 2005-01-28 16:56 |只看该作者

在linux中怎样在一个文档中查找一个字符串呢?

出现以下错误:
[root@proserver bandwidthd-1.2.1b]# sed -i's/top20/top100/g'graph.c
sed: invalid option -- i
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be e
      --help     display this help and exit
  -V, --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

E-mail bug reports to: bug-gnu-utils@gnu.org .
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
[root@proserver bandwidthd-1.2.1b]# sed -i s/top20/top100/g graph.c
sed: invalid option -- i
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be e
      --help     display this help and exit
  -V, --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

E-mail bug reports to: bug-gnu-utils@gnu.org .
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
6 [报告]
发表于 2005-01-28 16:58 |只看该作者

在linux中怎样在一个文档中查找一个字符串呢?

原帖由 "congcn"]le 发表:
...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
  -e script, --expression=script
                 add the script to the commands to be executed
  -f..........

那是sed版本的问题!
这样:

  1. vim -e -s -c ":%s/top20/top100/g" -c ":wq!" urfile
复制代码

论坛徽章:
0
7 [报告]
发表于 2005-01-28 17:28 |只看该作者

在linux中怎样在一个文档中查找一个字符串呢?

还是错误,你那个:是分号还是冒号呢?

论坛徽章:
0
8 [报告]
发表于 2005-01-28 17:29 |只看该作者

在linux中怎样在一个文档中查找一个字符串呢?

长见识

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
9 [报告]
发表于 2005-01-28 17:38 |只看该作者

在linux中怎样在一个文档中查找一个字符串呢?

[quote]原帖由 "congcn"]还是错误,你那个:是分号还是冒号呢?[/quote 发表:

:

论坛徽章:
0
10 [报告]
发表于 2005-01-28 17:43 |只看该作者

在linux中怎样在一个文档中查找一个字符串呢?

urfile  这个是不是要查找的文件吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP