Sponsored Content
Top Forums UNIX for Advanced & Expert Users replacing first line or lines in a file Post 302077286 by blowtorch on Wednesday 21st of June 2006 03:40:48 AM
Old 06-21-2006
Are you looking for something like this:
Code:
# cat test
this is line 1
this is line 2
this is line 3
# sed '1s/this is line/that is line/' test
that is line 1
this is line 2
this is line 3
# sed '2s/this is line/that is line/' test
this is line 1
that is line 2
this is line 3

Members may be able to help you better if you posted a part of the file you are working with and exactly what you are trying to do with the file.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replacing specific lines in a file

Hi there I have a file which has the lines # Serial number for hostid EXP_SERIAL_="" These lines could be anywhere in the file as far as line numbers go, I would like replace these two lines with # Serial number for hostid $var1 EXP_SERIAL_$var1="$var2" Is there a quick and simple... (6 Replies)
Discussion started by: hcclnoodles
6 Replies

2. Shell Programming and Scripting

replacing multiple lines with single line

Can any one give me the idea on replacing multiple blank lines with a single blank line? Please conside it for a file having more than 100 number of characters. Regards, Siba (3 Replies)
Discussion started by: siba.s.nayak
3 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 line 'i' of file1 with line 'j' of file 2

Hi All, As mentioned in the title I have two text files and I would like to replace line number 5 of file #1 with line number 4 of file #2 e.g. file 1 wqwert 4.4464002 3 319 286 369 46.320002 56.150002 45.100002 1 1 1 0.723 (12 Replies)
Discussion started by: f_o_555
12 Replies

5. Shell Programming and Scripting

replacing multi lines with 1 line

I have an xml file that is stripped down to output that looks bacically like; <!-- TABLEA header --> <tablea> some fields </tablea> <!-- TABLEB header --> <!-- TABLEC header --> <tablec> some fields </tablec> I want to remove the header... (3 Replies)
Discussion started by: Griffs_Revenge
3 Replies

6. UNIX for Dummies Questions & Answers

Replacing 2 lines by single line

Hi I have a file with below content : a b S I need to replace the lines which have a and b continuously by d. d S I have used the below code tr '\n' '#'<file|sed. 's/a#b/d/g's?|tr '#' '\n' where # is not occurring anywhere in the file.. Is there any other efficient way to do this? ... (7 Replies)
Discussion started by: pandeesh
7 Replies

7. Shell Programming and Scripting

Replacing a single line with multiple lines in a file

Hi Am confused with the usage of "sed" command I want to replace a single line with multiple lines of a file.. eg., A file has Hi, How are you? I need to replace as Am fine What are You doing? I used the script as string1="Hi, How are you?" echo "$string1 is the value"... (4 Replies)
Discussion started by: Priya Amaresh
4 Replies

8. Shell Programming and Scripting

Replacing lines matching a multi-line pattern (sed/perl/awk)

Dear Unix Forums, I am hoping you can help me with a pattern matching problem. What am I trying to do? I want to replace multiple lines of a text file (that match a multi-line pattern) with a single line of text. These patterns can span several lines and do not always have the same number of... (10 Replies)
Discussion started by: thefang
10 Replies

9. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 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
forward(4)						     Kernel Interfaces Manual							forward(4)

NAME
forward - forward mail SYNOPSIS
/var/adm/forward/username $HOME/.forward DESCRIPTION
The .forward file allows a user to forward messages to another host, or to invoke programs (such as vacation(1)) to process their mail. It is formatted as a series of comma-separated addresses in the form: addr_1, addr_2, ... Alternatively, each address can be on a separate line. The newer sendmail.v8 program also allows the use of comments (lines that begin with a ``#'') and blank lines. As with the aliases(4) file, mail messages can be forwarded to another host or given to programs for further processing. The following is an example of the vacation program. Assuming that the user's name is myra, create a .forward file and add the following line: myra, "|/usr/bin/vacation myra" The previous example forwards mail to myra (the backslash prevents an accidental aliasing loop), and also sends a copy of the message to the vacation program. For security reasons, the file must be owned by the user or by root and it should be writable only by the file owner. In addition, the file must be readable by the owner (myra) or root. On traditional systems, only the $HOME/.forward file is checked. The sendmail.v8 program allows the use of the system-wide forwarding directory /var/adm/forward. By default, this directory is checked for a forward file prior to examining the users $HOME directory. FILES
System-wide forwarding file. The per-user forwarding file. RESTRICTIONS
The sendmail command can hang trying to read the user's $HOME/.forward file. If the user's home directory is NFS-mounted and temporarily unavailable, sendmail will stall until the directory becomes available again. The use of non-NFS mounted directories for the forwarding of files is recommended. The use of /var/adm/forward is supported only by sendmail.v8. The actual path for /var/adm/forward is configurable in the sendmail.cf file. Incorrect file permissions/ownership are quietly ignored. It is easy to create an accidental loop, for example, on host_a myra@host_b and on host_b myra@host_a RELATED INFORMATION
Commands: aliases(4), sendmail.cf(4), sendmail(8) delim off forward(4)
All times are GMT -4. The time now is 05:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy