09-14-2008
Replace Entire line if any part matches regexp
Hey guys, I have a file that I've slowly been awking, seding, and greping for data entry. I am down to pull the addresses out to insert them into an excel file. Each address is a few lines, but i want to put a semicolon delimiter in between each address so I can export the text file into excel and have a column of address that matches up with other customer info. Some of the customers' records do not contain address info, but all of them contain the field " CONTACT: Name" after the adress, like so:
Address line 1
Address line 2
CONTACT: Name
Address line 1
Address line 2
CONTACT: Name
Can anyone help me turn the CONTACT line into a delimeter, or suggest something simpler, I would GREATLY appreciate it as there are many entires. NOTE: Not all address contain 2 lines, some have 4, some have 0. ALL of them contain the CONTACT line
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a perl function in my script that needs to replace an entire line in a file
sub changestate {
my $base = ();
my @base = ();
open(BASE, $file) || die("Could not open file!");
@base=<BASE>;
close (BASE);
foreach $base(@base)
{
if($base =~... (1 Reply)
Discussion started by: insania
1 Replies
2. Shell Programming and Scripting
hey gurus,
my-build1-abc
my-build10-abc
my-build2-abc
my-build22-abc
my-build3-abc
basically i want to numerically sort the entire lines based on the build number. I dont zero pad the numbers because thats "how it is" ;-)
sort -n won't work because it starts from the beginning.
... (10 Replies)
Discussion started by: gurpal2000
10 Replies
3. Shell Programming and Scripting
Hello,
I would like to delete all the footnotes in all my htm files. Hence, I have to delete the whole font tag pairs, i.e. deleting everything between the begin/end font tags.
I create a testfile, of which data parts of all four lines are the same except for the number of font tag pairs,... (3 Replies)
Discussion started by: cibalo
3 Replies
4. UNIX for Advanced & Expert Users
Hi everyone
I am new to Unix. I got stuck up by small issue.
I have text file something like this
abc 'xyz' '5'
lmn 'pqr' '7'
i want to replace the abc 'xyz' '5' to abc 'xyz' '6'
but i have a key as 'xyz' based on this key i want to do that.
I am not aware of how to use sed... (7 Replies)
Discussion started by: Vijayaragavan
7 Replies
5. Shell Programming and Scripting
I want to replace one line from my configuration file with the new settings.
The file Name: /etc/httpd/conf/httpd.conf
The following line should be replaced with the line mentioned below.
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "\"%h\"... (3 Replies)
Discussion started by: shantanuo
3 Replies
6. Shell Programming and Scripting
Hey Fellas.
I am new to scripting. I have searched through the forums and found a lot of good info, but I can't seem to get any of it to work together. I am trying to find a particular sting in a file, and if the next string matches certain criteria, replace it with a string from a csv... (6 Replies)
Discussion started by: midniteslice
6 Replies
7. Shell Programming and Scripting
Hi,
I need to replace an entire mailx line as follows using sed:
sed -e 's/<line1>/<newline>/g' <filename>
But I am getting comman garbled error since the new line has many special characters. I enclosed allspecial chars in \ but still no use.
Can any one help me?
Please use code... (2 Replies)
Discussion started by: vinodhin4
2 Replies
8. Shell Programming and Scripting
Hi All,
I have a file testarun.txt contains the below lines and i want to print the lines if the character positions 7-8 matches 01.
201401011111
201401022222
201402013333
201402024444
201403015555
201403026666
201404017777
201404028888
201405019999
201405020000
I am trying the... (4 Replies)
Discussion started by: Arunprasad
4 Replies
9. Shell Programming and Scripting
I have one requirement to delete all lines from a file if it matches below scenario. File contains three column. Employee Number, Employee Name and Employee ID
Scenario is: delete all line if Employee Number (1st column) contains below
1. Non-numeric Employee Number
2. Employee Number that... (3 Replies)
Discussion started by: anshu ranjan
3 Replies
10. UNIX for Beginners Questions & Answers
I have a list of value , and need to replace that in my file.
Eg:
File1
tcname:fail
tcname: Pass
tcname:skipped
File2:
01,02,03
Output:
File 1
01:fail
02: Pass
03:Skipped (8 Replies)
Discussion started by: DevAakash
8 Replies
LEARN ABOUT OPENSOLARIS
sip_create_okack
sip_create_OKack(3SIP) Session Initiation Protocol Library Functions sip_create_OKack(3SIP)
NAME
sip_create_OKack - create an ACK request for a final response
SYNOPSIS
cc [ flag ... ] file ... -lsip [ library ... ]
#include <sip.h>
int sip_create_OKack(sip_msg_t response,
sip_msg_t ack_msg, char *transport,
char *sent_by, int sent_by_port,
char *via_params);
DESCRIPTION
The sip_create_OKack() function constructs an ACK request in ack_msg for the final 2XX SIP response. The request line is created using the
URI in the CONTACT header from the response. The SIP-Version in the request line is "2.0". The VIA header for the ACK request is created
using transport, sent_by, sent_by_port (if non-zero), and via_params (if non-null). The following headers are copied to ack_msg from
response:
FROM
TO
CALL-ID
MAX_FORWARDS
The CSEQ header is created using the method as ACK and the sequence number from the CSEQ header in response.
RETURN VALUES
The sip_create_OKack() function returns 0 on success and the appropriate error value in case of failure.
The value of errno is not changed by these calls in the event of an error.
ERRORS
On failure, the sip_create_OKack() function could return one of the following errors:
EINVAL If mandatory input is not provided or if the input is invalid.
The sip_create_OKack() function can return this error if it does not find a CONTACT header or if it is unable to obtain the URI
from the CONTACT header for the request line.
ENOTSUP If the input SIP message cannot be modified.
ENOMEM If memory allocation fails when creating the request/response line or when creating headers in the ACK request.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Committed |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO
libsip(3LIB)
SunOS 5.11 25 Jan 2007 sip_create_OKack(3SIP)