Sponsored Content
Top Forums Shell Programming and Scripting replacing specific lines in a file Post 302091138 by hcclnoodles on Friday 29th of September 2006 09:46:41 AM
Old 09-29-2006
thats great but if i run that command from the command line it outputs the correct result to the screen but doesnt actually edit the file


How do i get it to make a permanent change to the file ??
 

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
edinplace(1)							Mail Avenger 0.8.3						      edinplace(1)

NAME
edinplace - edit a file in place SYNOPSIS
edinplace [--error=code] [[--file=file] command [arg ...]] DESCRIPTION
edinplace runs command with its input from file (or standard input by default), and then replaces the contents of file with the output of command. To the extent possible, edinplace attempts to exit with the same status as command. If edinplace is run on standard input (no --file option), it must inherit a file descriptor 0 that is open for both reading and writing. When processing standard input, if edinplace does not encounter a fatal error, it rewinds its standard input to offset 0 before exiting. Thus, a script can first run edinplace command, then run another filter command such as grep, and the resulting output will be the output of grep on command's output. If no command is specified, edinplace just rewinds its standard input to file offset 0. In this case, it is an error to supply the --file option. Of course, rewinding only works when standard input is a real file (as opposed to a pipe or device). There are two options: --error=code (-x code) Ordinarily, edinplace attempts to exit with the same status as command. However, if edinplace encounters some fatal error (such as being unable to execute command), it will exit with status code. The default value is 1. The range of valid exit codes is 1-255, inclusive. --file=file (-f file) Specifies that file should be edited. Otherwise, edinplace will edit its standard input (which must be opened for both reading and writing). --skipfrom Skip the first line of the file if it starts "From ". If edinplace is run without a command, positions the file offset at the start of the second line of the file. If edinplace is run with a command, then the first line of the file is neither fed to the command, nor overwritten. This option is useful for running edinplace over mail files, which sometimes start with a "From " line specifying the envelope sender of the message. Since "From " is not part of the message header, just a Unix convention, some programs are confused by the presence of that line. Note that if you specify a command, then edinplace resets the file offset to 0 upon exiting, even if the --skipfrom option was present. EXAMPLES
The following command prepends the string "ORIGINAL: " to the beginning of each line in text file message: edinplace -f message sed -e 's/^/ORIGINAL: /' The following command runs the spamassassin mail filter program on a mail message stored in file message, replacing the contents of message with spamassassin's annotated output, and exiting with code 100 if spamassassin thinks the message is spam. If edinplace encounters any fatal errors, it will exit with code 111. edinplace -x 111 -f message spamassassin -e 100 (spamassassin reads a mail message on standard input and outputs an annotated copy of the message including information about whether or not the message is likely to be spam and why. The -e option to spamassassin specifies what exit status spamassassin should use if the message appears to be spam; edinplace will use the same exit code as the program it has run.) To run spamassassin on incoming mail before accepting the mail from the remote client, place the following line in an appropriate Mail Avenger rcpt file as the last command executed: bodytest edinplace -x 111 spamassassin -e 100 SEE ALSO
avenger(1) The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
edinplace does not make a copy of the file being edited, but rather overwrites the file as it is being processed. At any point where command has produced more output than it has consumed input from the file, edinplace buffers the difference in memory. Thus, a command that outputs large amounts of data before reading the input file can run edinplace out of memory. (A program that outputs data as it reads even a very large file should be fine, however.) If command crashes or malfunctions for any reason, you will likely lose the input file, since edinplace will view this as a program that simply outputs the empty file. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 edinplace(1)
All times are GMT -4. The time now is 12:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy