由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - shell script help?
相关主题
help on sedCGI之Perl Script一问
shell script question请问几个关于Sed的问题
How to extract Last string in one line (Windows NT SHELL script)有关Unix shell script的问题
a question about renameShell programming problem, Thx!
帮帮忙,用C作一个SHELL请问怎么修改所有文件里面的字符串
how to redirect error output under unixunix shell help?
为什么time命令无法重定向?提示我 too many ('s 怎么办?
Perl问题求助 (转载)which shell is best?
相关话题的讨论汇总
话题: 12345话题: 54321话题: script话题: shell话题: vi
进入Unix版参与讨论
1 (共1页)
j***y
发帖数: 2074
1
If I want to replace the string "12345" (in the file test.c) with "54321", how
to make it with shell script or in vi?
thanks,
o**v
发帖数: 1662
2
j***y
发帖数: 2074
3
What's the effect of ^m?
Btw, the file contains more than one instance of the string "12345". Still the
same script in vi?
thanks,

how

【在 o**v 的大作中提到】

o**v
发帖数: 1662
4
^m=回国
global, try
o**v
发帖数: 1662
5
是回车,不好意思【 在 ooev (我所说的一切都可作为灌水证供) 的大作中提到: 】
j***y
发帖数: 2074
6

It failed.
I opened test.c with vi (vi test.c), and type ":s/12345/54321/g^m", right?

【在 o**v 的大作中提到】
: ^m=回国
: global, try

t*******y
发帖数: 57
7
ft,just type":s/12345/54321/g"

【在 j***y 的大作中提到】
:
: It failed.
: I opened test.c with vi (vi test.c), and type ":s/12345/54321/g^m", right?

j***y
发帖数: 2074
8

still the error: Substitute pattern match failed.
But I can confirm the string's existence by using "/12345" to find it.
Another finding is: when i move the cursor to the beginning of string 12345,
and type the above command, it can be replaced. But even in this case, it
can't be replaced globally. only change one instance. :(

【在 t*******y 的大作中提到】
: ft,just type":s/12345/54321/g"
t*******y
发帖数: 57
9
type":% s/12345/54321/g"

【在 j***y 的大作中提到】
:
: still the error: Substitute pattern match failed.
: But I can confirm the string's existence by using "/12345" to find it.
: Another finding is: when i move the cursor to the beginning of string 12345,
: and type the above command, it can be replaced. But even in this case, it
: can't be replaced globally. only change one instance. :(

j***y
发帖数: 2074
10

Thanks, it works finally.
A minor correction: there shouldn't be space character between % and s.
So my working command is ":%s/12345/54321/g".
Thanks again.

【在 t*******y 的大作中提到】
: type":% s/12345/54321/g"
相关主题
how to redirect error output under unixCGI之Perl Script一问
为什么time命令无法重定向?请问几个关于Sed的问题
Perl问题求助 (转载)有关Unix shell script的问题
进入Unix版参与讨论
c****s
发帖数: 37
11
sed -i -e "s/12345/54321/g" filename

【在 j***y 的大作中提到】
: If I want to replace the string "12345" (in the file test.c) with "54321", how
: to make it with shell script or in vi?
: thanks,

j***y
发帖数: 2074
12

Thanks, this works perfectly, too. :)

【在 c****s 的大作中提到】
: sed -i -e "s/12345/54321/g" filename
a***r
发帖数: 35
13
sed -e "s/12345/54321/g" file

【在 j***y 的大作中提到】
: If I want to replace the string "12345" (in the file test.c) with "54321", how
: to make it with shell script or in vi?
: thanks,

a***r
发帖数: 35
14
o ft 已经有人回了。。

【在 c****s 的大作中提到】
: sed -i -e "s/12345/54321/g" filename
c****s
发帖数: 37
15
lol, 还需要-i吧,否则只是输出到stdout:)

【在 a***r 的大作中提到】
: sed -e "s/12345/54321/g" file
a***r
发帖数: 35
16
oh~ 土了。。我一直都是用重定向 然后rename

【在 c****s 的大作中提到】
: lol, 还需要-i吧,否则只是输出到stdout:)
1 (共1页)
进入Unix版参与讨论
相关主题
which shell is best?帮帮忙,用C作一个SHELL
shell programminghow to redirect error output under unix
where can I find some good website for C Shell ?为什么time命令无法重定向?
Shell ScriptPerl问题求助 (转载)
help on sedCGI之Perl Script一问
shell script question请问几个关于Sed的问题
How to extract Last string in one line (Windows NT SHELL script)有关Unix shell script的问题
a question about renameShell programming problem, Thx!
相关话题的讨论汇总
话题: 12345话题: 54321话题: script话题: shell话题: vi