Sponsored Content
Top Forums Shell Programming and Scripting replacing specific lines in a file Post 302091250 by mph on Saturday 30th of September 2006 11:35:12 AM
Old 09-30-2006
You might try something like this if you don't want to create a file:
Code:
echo '%s/oldtext/newtext/g\nwq' | ex file

This will edit the text within the file. Non interactive style vi. The exact syntax for ex is a bit murky I can't find a lot of docs on it, but in a few occasions it's well worth figuring out and using.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

replacing first line or lines in a file

hey guys, how do i replace only a line within a file without messing up the rest of the contents of the file? see, if possible can you guys give me a straight forward way to do this. i dont want a complex command. what i mean is i know i can accomplish this by using sed, well, i think i can,... (3 Replies)
Discussion started by: Terrible
3 Replies

2. UNIX for Dummies Questions & Answers

how to display specific lines of a specific file

are there any basic commands that can display lines 99 - 101 of the /etc/passwd file? I'm thinking use of head and tail, but I forget what numbers to use and where to put /etc/passwd in the command. (2 Replies)
Discussion started by: raidkridley
2 Replies

3. Shell Programming and Scripting

Replacing Block of lines in a text file

Dear All, Regards of the Day. I have a text file with some functions: Function1 { parameter 1 parameter 2 parameter 3 } end Function2 { parameter 1 parameter 2 parameter 3 } (1 Reply)
Discussion started by: ashisharora
1 Replies

4. Shell Programming and Scripting

replacing field in specific line in a file

Hi, I know there are lots of threads on replacing text within files, usually using sed or awk. However, I find it hard to adapt examples that I found to my specific case. I am kind of new to UNIX and have hard times learning the syntax either for sed or awk so I would appreciate any help. Here's... (5 Replies)
Discussion started by: vytenis
5 Replies

5. UNIX for Dummies Questions & Answers

Replacing all cells that have a specific value in a text file

I have a space delimited text file where I want to replace all cells that are 0 with NA. However I cannot simply use 'sed/0/NA/g' because there are other 0's in the text file that are part of numbers. Example input: 896.933464285715 0 874.691732142857 866.404660714286 Output:... (1 Reply)
Discussion started by: evelibertine
1 Replies

6. Shell Programming and Scripting

Replacing specific lines with another lines

Hi, I have a file with many lines, then i have following list of lines(line number 5,12,19,5,and 28) i need to replace these lines of a file with another lines as shown below these text contains special charecter like= (/:;){} Line_number Text to replace with 5 abc... (1 Reply)
Discussion started by: MILAN KUMAR
1 Replies

7. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum using sed, awk

Hi friends, This is sed & awk type question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example ###start of input text file #### abc def ghi 1 2 3 4 kjld random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

8. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum

Hi friends, This is sed & awk type question. It is slightly different from my previous question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers (but no more than 10 numbers in series) whenever i find it and produce an output file with the... (4 Replies)
Discussion started by: kaaliakahn
4 Replies

9. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 Replies

10. Shell Programming and Scripting

Matching and Replacing file lines starting with $

Here is the task that I was presented with: I am dealing with about a 10,000 line input deck file for an analysis. About 10 separate blocks of around 25 lines of code each need to be updated in the input deck. The input deck (deckToChange in the code below) comes with 2 separate files. File 1... (5 Replies)
Discussion started by: tiktak292
5 Replies
curs_scroll(3CURSES)					     Curses Library Functions					      curs_scroll(3CURSES)

NAME
curs_scroll, scroll, scrl, wscrl - scroll a curses window SYNOPSIS
cc [ flag ... ] file ... -lcurses [ library ... ] #include <curses.h> int scroll(WINDOW *win); int scrl(int n); int wscrl(WINDOW *win, int n); DESCRIPTION
With the scroll() routine, the window is scrolled up one line. This involves moving the lines in the window data structure. As an optimiza- tion, if the scrolling region of the window is the entire screen, the physical screen is scrolled at the same time. With the scrl() and wscrl() routines, for positive n scroll the window up n lines (line i+n becomes i); otherwise scroll the window down n lines. This involves moving the lines in the window character image structure. The current cursor position is not changed. For these functions to work, scrolling must be enabled via scrollok(). RETURN VALUES
All routines return the integer ERR upon failure and an integer value other than ERR upon successful completion. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
curs_outopts(3CURSES), curses(3CURSES), attributes(5) NOTES
The header <curses.h> automatically includes the headers <stdio.h> and <unctrl.h>. Note that scrl() and scroll() may be macros. SunOS 5.10 31 Dec 1996 curs_scroll(3CURSES)
All times are GMT -4. The time now is 05:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy