06-08-2006
how to insert line break + string in vi (search & replace )
Hello all
i have big test file that has allot of structure text something like this :
<foo1 *.html>
<blah action>
somthing 1
somthing 2
</blah>
</foo1 >
now i will like to insert 2 more lines of text below the <blah action>
so it will be like :
<foo1 *.html>
<blah action>
param1 off
param2 off
somthing 1
somthing 2
</blah>
</foo1 >
i need to be able to insert it all across the text file .
i know i can do search and replace in vi with
%s/action\>$/.........../g
but i don't know how to tell the replace command to insert line brakes ( i think this is what i need)
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hey, I want to have a C program which, for an existing file supplied by the command line argument (E.g. File1.txt) replaces all the occurrences of the words:
"We” or “we” by “I”
“a” by “the”
“A” by “The”.
Then print the replaced file. All other characters of the file are to be left... (1 Reply)
Discussion started by: IwishIknewC
1 Replies
2. UNIX for Dummies Questions & Answers
I want to carry out search & replace for the paths mentioned in the file with the help of vi.
'abc/' to be replaced by 'abc/data'
When I use command in vi as below -
%s/abc//abc/data/g
it gives me an error.
How we should deal with '/' part in string for vi search & replace?
... (6 Replies)
Discussion started by: videsh77
6 Replies
3. Shell Programming and Scripting
Hi All,
I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text.
An example of 4 lines in my file is:
1. MatchText_randomNumberOfText moreData ReplaceMe moreData
2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies
4. Shell Programming and Scripting
Hi, guys. I have one question:
How can I search for a line with certain string in it and then insert a string into this line?
For example:
There is a file called shadow, the contents of it are below:
**************************
...
yuanz:VIRADxMsadfDF/Q:0:0:50:7:::... (9 Replies)
Discussion started by: daikeyang
9 Replies
5. Shell Programming and Scripting
Hi,, Please excuse my lack of knowledge here. I think I am tring to do something fairly advanced yet am a bit of a beginner.....
I want to use a korn shell (as is the norm with others in my company) to write a script to search a file for a string and insert some text above that line.
Sudo... (5 Replies)
Discussion started by: HugoDarley
5 Replies
6. Shell Programming and Scripting
Dear All,
thanks in advance
input file
410530AAANNNNNAAA410530JJJJJJYYYY410530PPPPPAAAAAA...........
I want output like
410530AAANNNNNAAA
410530JJJJJJYYYY
410530PPPPPAAAAAA
Thanks (10 Replies)
Discussion started by: The_Archer
10 Replies
7. UNIX for Dummies Questions & Answers
Hi:
I have 2 files: teststring.txt and a tempfile.txt
teststring file contains:
s/Primary Ins./\n1/g
I'm trying to search for "Primary Ins." string in tempfile. For every "Primary Ins." string that is found, a new line is inserted and put in number 1. Then, write out the newfile... (7 Replies)
Discussion started by: newbeee
7 Replies
8. Shell Programming and Scripting
Hello guys,
I need your help for a specific sed command that would search for a multi line pattern and if found, would replace it by another multi line pattern.
For instance, here is the input:
<RefNickName>abcd</RefNickName>
<NickName>efgh</NickName>
<Customize>
... (0 Replies)
Discussion started by: xciteddd
0 Replies
9. Shell Programming and Scripting
Hi,
I need to search for source path in file2 , as per file1 and if found get the next line and take the field value and put it in URL value of file1.
In file1, NF is not same for all the lines.
file1:
<type source="/home/USER/Desktop" Dest="/home/USER/DIR1/Desktop" URL="ssh/path"/>
<type... (8 Replies)
Discussion started by: greet_sed
8 Replies
10. UNIX for Dummies Questions & Answers
Hi Everyone,
I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file.
I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies
LEARN ABOUT OSF1
dxmcstextreplace
DXmCSTextReplace(3X) DXmCSTextReplace(3X)
NAME
DXmCSTextReplace - Replaces a specified segment of text in a compound string text widget.
SYNOPSIS
DXmCSTextStatus DXmCSTextReplace(
Widget widget,
int from_pos,
int to_pos,
XmString value );
PARAMETERS
The identifier (widget ID) of the compound string text widget. An integer that represents the first character position of the text being
replaced. An integer that represents the last character position of the text being replaced. Replacement text for part of the current
text in the compound string text widget, or additional text to be inserted into the compound string text widget.
DESCRIPTION
The DXmCSTextReplace routine replaces part of the text in the compound string text widget. Within the widget, positions are numbered
starting at 0 and increasing sequentially. For example, to replace the second and third characters in the text, from_pos should be 1 and
to_pos should be 3. To insert text after the fourth character, from_pos and to_pos should both be 4.
RETURN VALUES
A value that represents the status (success or failure) of the replace operation, as follows:
--------------------------------------------------------
Value Description
--------------------------------------------------------
DXmCSTextStatusEditDone Text replaced successfully.
DXmCSTextStatusEditError Text not replaced (failure).
--------------------------------------------------------
SEE ALSO
DXmCreateCSText(3X), DXmCSTextSetString(3X), DXmCSTextGetString(3X)
DXmCSTextReplace(3X)