Sponsored Content
Top Forums Shell Programming and Scripting sed / awk to concatenate lines until blank line Post 302302231 by dunstonrocks on Monday 30th of March 2009 12:09:27 PM
Old 03-30-2009
I am also trying to achieve this output, but I have failed with various sed solutions that I have tried.
-------------------------
SAMPLE INPUT
-------------------------
Name: ABCD
Address: ABCD Road, ABCD City, ABCD State
ZipCode: 0000
Telno: 999-999-9999

Name: EFGH
Address Temp Road, Temp City, Temp State
Telno 999-999-9999

----------------------
EXPECTED OUTPUT
----------------------

Name: ABCD
Address: ABCD Road, ABCD City, ABCD State
ZipCode: 0000
Telno: 999-999-9999

Name: EFGH
Address Temp Road, Temp City, Temp State
ZipCode: <--- This is the new entry
Telno 999-999-9999

Basically, the requirement is to insert a word between two words if the word does not already exist.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Need solution concatenate and display 2 lines as 1 with a condition for 2 line ?

I have 2 pattern of lines (SQL query and Time taken)in a log i need to capture all SQL queries with time taken >20 sec and need to display as one line. 2 lines from log: 2007-10-23 11:39:17,061 DEBUG - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN... (1 Reply)
Discussion started by: vithala
1 Replies

2. Shell Programming and Scripting

concatenate and display 2 lines as 1 with a condition for 2 line ?

I have 2 pattern of lines (SQL query and Time taken)in a log i need to capture all SQL queries with time taken >20 sec and need to display as one line. 2 lines from log: 2007-10-23 11:39:17,061 DEBUG - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN... (7 Replies)
Discussion started by: vithala
7 Replies

3. Shell Programming and Scripting

sed and blank lines

hello, i have tried to remove blank lines from a file using korn shell script file.. it doesn't seem to work! i tried sed '/^\s*$/d' infile > outfile but that didn't work i tried sed 's/ *$//;/^$/d' infile > outfile and that didn't work i tried sed '/^s./d' infile > outfile and that... (6 Replies)
Discussion started by: alrinno
6 Replies

4. UNIX for Advanced & Expert Users

need to concatenate two lines if the line doesnt end with quotes

Hi I am getting a source file where the columns are seperated by comma and double Quotes Eg1 : "AAA","BBB","CCCC" in the same source file i am also getting few lines where my last columns double quotes are ending in its next line or the next next line Eg2: "AAA","BBB","CCC CC"... (9 Replies)
Discussion started by: laxmi131
9 Replies

5. Shell Programming and Scripting

Logfile - extracting certain lines to concatenate into 1 line

I've got a log file from automatic diagnostic runs. The log file is appended to each time an automatic log is run. I'd like to just pull certain lines from each run in the log file, and concatenate them into 1 comma delimited line (for export into excel or an html table). Each diagnostic run... (3 Replies)
Discussion started by: BecTech
3 Replies

6. Shell Programming and Scripting

sed show lines text between 2 blank lines

I have a file like blah blah blah blah this is the text I need, which might be between 1-4 lines, but always has a blank line above and below it, and is at the end of the text file the code tags don't show the trailing blank line. I started by deleting the last blank line with: ... (2 Replies)
Discussion started by: unclecameron
2 Replies

7. Shell Programming and Scripting

sed or awk delete character in the lines before and after the matching line

Sample file: This is line one, this is another line, this is the PRIMARY INDEX line l ; This is another line The command should find the line with “PRIMARY INDEX” and remove the last character from the line preceding it (in this case , comma) and remove the first character from the line... (5 Replies)
Discussion started by: KC_Rules
5 Replies

8. Shell Programming and Scripting

awk or sed - Convert 2 lines to 1 line

Hi, Just trying to get to grips with sed and awk for some reporting for work and I need some assistance: I have a file that lists policy names on the first line and then on the second line whether the policy is active or not. Policy Name: Policy1 Active: yes Policy... (8 Replies)
Discussion started by: guinch
8 Replies

9. Shell Programming and Scripting

Awk, sed - concatenate lines starting with string

I have a file that looks like this: John Smith http://www.profile1.com http://www.profile2.com http://www.profile3.com Marc Olsen http://www.profile4.com http://www.profile5.com http://www.profile6.com http://www.profile7.com Lynne Doe http://www.profile8.com http://www.profile9.com... (3 Replies)
Discussion started by: locoroco
3 Replies

10. Shell Programming and Scripting

String search and print next all lines in one line until blank line

Dear all I want to search special string in file and then print next all line in one line until blank lines come. Help me plz for same. My input file and desire op file is as under. i/p file: A1/EXT "BSCABD1_21233G1" 757 130823 1157 RADIO X-CEIVER ADMINISTRATION BTS EXTERNAL FAULT ... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies
Color::Library::Dictionary::NBS_ISCC::SC(3pm)		User Contributed Perl Documentation	     Color::Library::Dictionary::NBS_ISCC::SC(3pm)

NAME
Color::Library::Dictionary::NBS_ISCC::SC - (NBS/ISCC SC) Soil Color Charts DESCRIPTION
Kenneth L. Kelly and Deanne B. Judd. "Color: Universal Language and Dictionary of Names", National Bureau of Standards, Spec. Publ. 440, Dec. 1976, 189 pages. Color Name Dictionary: (SC) Soil Color Charts U.S. Department of Agriculture Soil Color Charts This combinatorial field-work dictionary's 50 names mape to 176 colors, using 76 of 267 centroids. Again, its focus on soil colors limits its general usefulness. <http://swissnet.ai.mit.edu/~jaffer/Color/Dictionaries#SC> COLORS
black black #3e322c black black #28201c black black #3b3121 black black #363527 black black #25241d black black #222222 brown brown #a67b5b brown brown #6f4e37 brown brown #958070 brown brown #635147 brown brown #826644 brown brown #7e6d5a brownish yellow brownishyellow #be8a3d brownish yellow brownishyellow #c19a6b dark brown darkbrown #6f4e37 dark brown darkbrown #635147 dark brown darkbrown #826644 dark brown darkbrown #4b3621 dark brown darkbrown #7e6d5a dark gray darkgray #5b504f dark gray darkgray #57554c dark gray darkgray #555555 dark grayish brown darkgrayishbrown #7e6d5a dark grayish brown darkgrayishbrown #6c541e dark olive darkolive #665d1e dark olive darkolive #403d21 dark olive darkolive #363527 dark olive-gray darkolivegray #5b5842 dark red darkred #722f37 dark red darkred #882d17 dark red darkred #56070c dark red darkred #79443b dark red darkred #80461b dark reddish brown darkreddishbrown #79443b dark reddish brown darkreddishbrown #3e1d1e dark reddish brown darkreddishbrown #674c47 dark reddish brown darkreddishbrown #43302e dark reddish brown darkreddishbrown #6f4e37 dark reddish brown darkreddishbrown #422518 dark reddish brown darkreddishbrown #635147 dark reddish brown darkreddishbrown #3e322c dark reddish gray darkreddishgray #5c504f dark reddish gray darkreddishgray #635147 dark reddish gray darkreddishgray #5b504f dark yellowish brown darkyellowishbrown #996515 dark yellowish brown darkyellowishbrown #826644 dark yellowish brown darkyellowishbrown #4b3621 dusky red duskyred #79443b dusky red duskyred #674c47 gray gray #8e8279 gray gray #8a8776 gray gray #848482 grayish brown grayishbrown #7e6d5a grayish brown grayishbrown #967117 light brown lightbrown #a67b5b light brownish gray lightbrownishgray #ae9b82 light brownish gray lightbrownishgray #967117 light gray lightgray #c1b6b3 light gray lightgray #8e8279 light gray lightgray #ae9b82 light gray lightgray #c2b280 light gray lightgray #bfb8a5 light gray lightgray #8a8776 light gray lightgray #b9b8b5 light gray lightgray #848482 light olive brown lightolivebrown #967117 light olive-gray lightolivegray #8c8767 light olive-gray lightolivegray #8a8776 light red lightred #e66761 light red lightred #c48379 light red lightred #cb6d51 light red lightred #b4745e light red lightred #d99058 light reddish brown lightreddishbrown #a87c6d light reddish brown lightreddishbrown #977f73 light reddish brown lightreddishbrown #a67b5b light yellowish brown lightyellowishbrown #c19a6b light yellowish brown lightyellowishbrown #a18f60 olive olive #867e36 olive olive #665d1e olive olive #8c8767 olive olive #5b5842 olive brown olivebrown #6c541e olive brown olivebrown #3b3121 olive gray olivegray #8c8767 olive gray olivegray #5b5842 olive gray olivegray #8a8776 olive yellow oliveyellow #ab9144 pale brown palebrown #c19a6b pale brown palebrown #ae9b82 pale olive paleolive #a18f60 pale olive paleolive #8c8767 pale red palered #ad8884 pale red palered #a87c6d pale red palered #977f73 pale yellow paleyellow #f3e5ab pale yellow paleyellow #c2b280 pink pink #f4c2c2 pink pink #d9a6a9 pink pink #ecd5c5 pink pink #c7ada3 pink pink #c2ac99 pink pink #fad6a5 pink pink #c19a6b pinkish gray pinkishgray #c7ada3 pinkish gray pinkishgray #c2ac99 pinkish gray pinkishgray #977f73 pinkish gray pinkishgray #958070 pinkish white pinkishwhite #ecd5c5 pinkish white pinkishwhite #c7ada3 pinkish white pinkishwhite #c2ac99 red red #ab4e52 red red #905d5d red red #cb6d51 red red #9e4732 red red #b4745e red red #79443b red red #ae6938 red red #80461b reddish black reddishblack #282022 reddish black reddishblack #3e1d1e reddish black reddishblack #43302e reddish black reddishblack #3e322c reddish black reddishblack #28201c reddish brown reddishbrown #a87c6d reddish brown reddishbrown #79443b reddish brown reddishbrown #977f73 reddish brown reddishbrown #674c47 reddish brown reddishbrown #a67b5b reddish brown reddishbrown #6f4e37 reddish gray reddishgray #8f817f reddish gray reddishgray #977f73 reddish gray reddishgray #958070 reddish gray reddishgray #8e8279 reddish yellow reddishyellow #fab57f reddish yellow reddishyellow #d99058 reddish yellow reddishyellow #fbc97f reddish yellow reddishyellow #e3a857 reddish yellow reddishyellow #be8a3d strong brown strongbrown #80461b strong brown strongbrown #996515 very dark brown verydarkbrown #422518 very dark brown verydarkbrown #3e322c very dark brown verydarkbrown #4b3621 very dark brown verydarkbrown #483c32 very dark gray verydarkgray #5b504f very dark gray verydarkgray #57554c very dark gray verydarkgray #555555 very dark grayish brown verydarkgrayishbrown #483c32 very dark grayish brown verydarkgrayishbrown #6c541e very dusky red veryduskyred #3e1d1e very dusky red veryduskyred #43302e very pale brown verypalebrown #c2ac99 very pale brown verypalebrown #fad6a5 very pale brown verypalebrown #c19a6b very pale brown verypalebrown #ae9b82 weak red weakred #905d5d weak red weakred #a87c6d weak red weakred #79443b weak red weakred #977f73 weak red weakred #674c47 white white #eae3e1 white white #c1b6b3 white white #fad6a5 white white #f0ead6 white white #bfb8a5 white white #f2f3f4 white white #b9b8b5 yellow yellow #fbc97f yellow yellow #e3a857 yellow yellow #f8de7e yellow yellow #c9ae5d yellowish brown yellowishbrown #996515 yellowish brown yellowishbrown #826644 yellow red yellowred #ae6938 yellow red yellowred #80461b perl v5.14.2 2011-12-07 Color::Library::Dictionary::NBS_ISCC::SC(3pm)
All times are GMT -4. The time now is 12:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy