What if the number of lines of the original file is unknown ?
In my example I gave 3 lines but it can be anything between 1 and 20 lines.
In this case you will have to have some indication for a "record" being complete. Maybe you will need some record starting criteria too, for which one could match. Provide some data and i will provide some solution.
Quote:
Originally Posted by Browser_ice
I tried the combinations below which do not change anything or are not recognized
This is just a way to enter non-printing (control-) characters into vi: enter input mode, press "CTRL-V", then press CTRL-M (for example for "^M"). You should be still in input mode and see "^M" under the cursor.
Quote:
sed 's/.$//' does remove the ^M at the end of each line but then it is still a multi-line format.
It removes the last character in a line, regardless which character this is - this is the problem. You have to specifically match "^M" (CTRL-M) and throw that out. You can throw out linefeeds by searching for "\n". Try the following with some test file:
to see the effect: two lines combined to one and the linefeed is replaced by an at.
[quote]Is there a way to find out in VI what is the ascii value of the character under the cursor ?[/qoute]
Hi,
I have a situation where I want to replace some occurrences of ".jsp" into ".html" inside a text file.
For Example:
If a pattern found like <a href="http://www.mysite.com/mypage.jsp"> it should be retained.
But if a pattern found like <a href="../mypage.jsp"> it should be changed to... (4 Replies)
Hi I'm trying to replace text in a file based upon a pattern.
The pattern I'm looking for is:
<styleURL>#style0002</styleURL>
<name>#######6105#######</name>The # are seven alphanumeric characters before and after 6105.
I need it to replace that with this recursively:
... (4 Replies)
Hi
I need to create multiple text files from onc text file on AIX. The data of text files is as below:
**********************************************
**********************************************
DBVERIFY: Release 10.2.0.4.0 - Production on Tue Nov 10 13:45:42 2009
Copyright (c) 1982,... (11 Replies)
i am editing a big log file with the following pattern:
Date: xxxx Updated: name
Some log file text here
Date: eee Updated: ny
Some log file text here
Basically i want to remove all the text in a line before the "Updated" pattern. I sill want to print the other... (4 Replies)
Can someone help me with a sed command:
There will be multiple occurences in a file that look like this:
MyFunction(12c34r5)
and I need to replace that with just the 12c34r5 for every occurrence. The text between the parentheses will be different on each occurrence, so I can't search for that.... (4 Replies)
HI Folks,
I'm looking for a solution for this issue.
I want to find the Pattern 0/ and replace it with /. I'm just removing the leading zero. I can find the Pattern but it always puts literal value as a replacement.
What am I missing??
sed -e s/0\//\//g File1 > File2
edit by... (3 Replies)
I have a sample text format as given below
<Text Text_ID="10155645315851111_10155645333076543" From="460350337461111" Created="2011-03-16T17:05:37+0000" use_count="123">This is the first text</Text>
<Text Text_ID="10155645315851111_10155645317023456" From="1626711840902323"... (3 Replies)
i have a file which contains data seperated by comma. i want to replace text after 3rd occurrence of a comma.
the input file looks like this
abcdef,11/02/2015 11:55:47,1001,1234567812345678,12364,,abc
abcdefg,11/02/2015 11:55:47,01,1234567812345678,123,,abc
abcdefhih,11/02/2015... (4 Replies)
hi unix expert
is there any command in linux to repace a pattern in the text to another pattern?
many thanks
samad (2 Replies)
Discussion started by: abdossamad2003
2 Replies
LEARN ABOUT ULTRIX
vi
vi(1) General Commands Manual vi(1)Name
vi - screen editor
Syntax
vi [ -t tag ] [ +command ] [ -l ] [ -r ] [ -wn ] [ -x ] name...
Description
The (visual) editor is a display-oriented text editor based on The command and the command run the same code. You can access the command
mode of from within
The following is a list of some of the commands. See the vi Beginner's Reference Card and "An Introduction to Display Editing with vi" in
the Supplementary Documents, Volume 1: General User for more details on using
Screen Control Commands
<CTRL/L> Reprints current screen.
<CTRL/Y> Exposes one more line at top of screen.
<CTRL/E> Exposes one more line at bottom of screen.
Paging Commands
<CTRL/F> Pages forward one screen.
<CTRL/B> Pages back one screen.
<CTRL/D> Pages down half screen.
<CTRL/U> Pages up half screen.
Cursor Positioning Commands
j Moves cursor down one line, same column.
k Moves cursor up one line, same column.
h Moves cursor back one character.
l Moves cursor forward one character.
<RETURN> Moves cursor to beginning of next line.
0 Moves cursor to beginning of current line.
$ Moves cursor to end of current line.
<SPACE> Moves cursor forward one character.
nG Moves cursor to beginning of line n. Default is last line of file.
/pattern Moves cursor forward to next occurrence of pattern.
?pattern Moves cursor backward to next occurrence of pattern.
n Repeats last / or ? pattern search.
Text Insertion Commands
a Appends text after cursor. Terminated by <ESC>.
A Appends text at the end of the line. Terminated by <ESC>.
i Inserts text before cursor. Terminated by <ESC>.
I Inserts text at the beginning of the line. Terminated by <ESC>.
o Opens new line below the current line for text insertion. Terminated by <ESC>.
O Opens new line above the current line for text insertion. Terminated by <ESC>.
<DELETE> Overwrites last character during text insertion.
<ESC> Stops text insertion.
Text Deletion Commands
dw Deletes current word.
x Deletes current character.
dd Deletes current line.
D, d$ Deletes from cursor to end of line.
P Puts back text from the previous delete.
Text Change Commands
cw Changes characters of current word until stopped with escape key.
c$ Changes text up to the end of the line.
C, c$ Changes remaining text on current line until stopped by pressing the escape key.
~ Changes case of current character.
xp Transposes current and following characters.
J Joins current line with next line.
rx Replaces current character with x.
Buffer Usage Commands
[a-z]n yy Yanks n lines to the [a-z] buffer. Default is current line.
[a-z]n p Puts n yanked text lines from the a-z buffer, after the cursor.
Exiting vi
ZZ Exits and saves changes
:wq Writes changes to current file and quits edit session.
:q Quits edit session (no changes made).
The command uses all of the same edit or commands as However, does not allow you to write the file. See
Options-t tag Specifies a list of tag files. The tag files are preceded by a backslash () and are separated by spaces. The tag option should
always be the first entry.
+command Tells the editor to begin by executing the specified command. A useful example would be +/pattern to search for a pattern.
-l Sets the showmatch and lisp options for editing LISP code.
-r name Retrieves the last saved version of the name'd file in the event of an editor or system crash. If no file is specified, a list
of saved files is produced.
-wn Sets the default window size to n. This option is useful for starting in a small window on dialups. The -x option is available
only if the Encryption layered product is installed.
-x Causes to prompt for a key. The key is used to encrypt and decrypt the contents of the file. If the file contents have been
encrypted with one key, you must use the same key to decrypt the file.
Restrictions
Software tabs using ^T work only immediately after the autoindent.
Left and right shifts on intelligent terminals do not make use of insert and delete character operations in the terminal.
The wrapmargin option sometimes works incorrectly because it looks at output columns when blanks are typed. If a long word passes through
the margin and onto the next line without a break, then the line is not broken.
Insert/delete within a line can be slow if tabs are present on intelligent terminals, since the terminals need help in doing this cor-
rectly.
Saving text on deletes in the named buffers is somewhat inefficient.
The source command does not work when executed as :source; there is no way to use the :append, :change, and :insert commands, since it is
not possible to give on a :global you must Q to command mode, execute them, and then reenter the screen editor with or
See Alsoed(1), ex(1), view(1)
The Little Gray Book: An ULTRIX Primer
The Big Gray Book: The Next Step with ULTRIX
"An Introduction to Display Editing with Vi", Supplementary Documents, Volume 1: General User
vi(1)