Sponsored Content
Top Forums Shell Programming and Scripting awk;sed appending line to previous line.... Post 302328177 by jim mcnamara on Tuesday 23rd of June 2009 03:44:28 PM
Old 06-23-2009
Code:
/home/jmcnama> cat t.awk
awk ' /^E-Mail/ {printf(" %s\n", $0); found=1; next}
     !/^E-Mail/ {printf((found==1)? "%s" : "\n%s", $0); found=0 } END {print ""} ' filename


/home/jmcnama> cat filename
User1NameLast User1NameFirst User1Address
E-Mail:User1email
not email
just filler
User2NameLast User2NameFirst User2Address
E-Mail:User2email
User3NameLast User3NameFirst User3Address
E-Mail:User3email
more filler and junk
User4NameLast User4NameFirst User4Address
E-Mail:User4email


/home/jmcnama> t.awk

User1NameLast User1NameFirst User1Address E-Mail:User1email
not email
just filler
User2NameLast User2NameFirst User2Address E-Mail:User2email
User3NameLast User3NameFirst User3Address E-Mail:User3email
more filler and junk
User4NameLast User4NameFirst User4Address E-Mail:User4email

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending line/lines with sed

Hi folks, I need to append line or bulk of lines into a file. For example,I have the following section in opmn.xml file: <process-type id="OC4J_RTEadmin_NIR" module-id="OC4J"> <module-data> <category id="start-parameters"> <data... (28 Replies)
Discussion started by: nir_s
28 Replies

2. UNIX for Dummies Questions & Answers

SED or AWK: Appending a line Identifier that changes with paragraph?

Have another question that has been eluding me all day. I have data file I'm trying to reformat so that each line is appended with an ID code, but the ID code needs to update as it searches through the file. I.e. ----Begin Original Datafile----- Condition = XXX Header Line 1 Header... (1 Reply)
Discussion started by: selkirk
1 Replies

3. Shell Programming and Scripting

Sed - Appending a line with a variable on it

Hi, I searched the forum for this but couldn't find the answer. Basically I have a line of code I want to insert into a file using sed. The line of code is basically something like "address=1.1.1.1" where 1.1.1.1 is an IP Address that will vary depending on what the user enters. I'll just refer... (4 Replies)
Discussion started by: eltinator
4 Replies

4. Shell Programming and Scripting

sed: appending alternate line after previous line

Hi all, I have to append every alternate line after its previous line. For example if my file has following contents line 1: unix is an OS line 2: it is open source line 3: it supports shell programming line 4: we can write shell scripts Required output should be line1: unix is an OS it is... (4 Replies)
Discussion started by: rish_max
4 Replies

5. Shell Programming and Scripting

SED or AWK "append line to the previous line"

Hi, How can I remove the line beak in the following case if the line begin with the special char “;”? TEXT Text;text ;text Text;text;text I want to convert the text to: Text;text;text Text;text;text I have already tried to use... (31 Replies)
Discussion started by: research3
31 Replies

6. Shell Programming and Scripting

Appending string (charachters inside the line) to a fixed width file using awk or sed

Source File: abcdefghijklmnop01qrstuvwxyz abcdefghijklmnop02qrstuvwxyz abcdefghijklmnop03qrstuvwxyz abcdefghijklmnop04qrstuvwxyz abcdefghijklmnop05qrstuvwxyz Whatever characters are in 17-18 on each line of the file, it should be concatenated to the same line at the character number... (6 Replies)
Discussion started by: tamahomekarasu
6 Replies

7. Shell Programming and Scripting

awk get matched line's previous line

hi everyone, a b in c d e f in g output is: a e so awk search for "in", then print out the matched line's previuos line. Please advice. (11 Replies)
Discussion started by: jimmy_y
11 Replies

8. Shell Programming and Scripting

Sed Comparing Parenthesized Values In Previous Line To Current Line

I am trying to delete lines in archived Apache httpd logs Each line has the pattern: <ip-address> - - <date-time> <document-request-URL> <http-response> <size-of-req'd-doc> <referring-document-URL> This pattern is shown in the example of 6 lines from the log in the code box below. These 6... (1 Reply)
Discussion started by: Proteomist
1 Replies

9. Shell Programming and Scripting

awk script -print line when $2 > $2 of previous line

Hi all, From a while loop I am reading a sorted file where I want to print only the lines that have $1 match and $2 only when the difference from $2 from the previous line is > 30. Input would be like ... AN237 010 193019 0502 1 CSU Amoxycillin AN237 080 ... (2 Replies)
Discussion started by: gafoleyo73
2 Replies

10. UNIX for Beginners Questions & Answers

awk or sed to print the character from the previous line after the regexp match

Hi All, I need to print the characters in the previous line just before the regular expression match Please have a look at the input file as attached I need to match the regular expression ^ with the character of the previous like and also the pin numbers and the output file should be like... (6 Replies)
Discussion started by: kshitij
6 Replies
Mail::SPF::Term(3pm)					User Contributed Perl Documentation				      Mail::SPF::Term(3pm)

NAME
Mail::SPF::Term - SPF record term class DESCRIPTION
An object of class Mail::SPF::Term represents a term within an SPF record. Mail::SPF::Term cannot be instantiated directly. Create an instance of a concrete sub-class instead. Constructor The following constructor is provided: new(%options): returns Mail::SPF::Term Abstract. Creates a new SPF record term object. %options is a list of key/value pairs, however Mail::SPF::Term itself specifies no constructor options. new_from_string($text, %options): returns Mail::SPF::Term; throws Mail::SPF::ENothingToParse, Mail::SPF::EInvalidTerm Abstract. Creates a new SPF record term object by parsing the string and any options given. Class methods The following class methods are provided: name_pattern: returns Regexp Returns a regular expression that matches any legal name for an SPF record term. Instance methods The following instance methods are provided: text: returns string; throws Mail::SPF::ENoUnparsedText Returns the unparsed text of the term. Throws a Mail::SPF::ENoUnparsedText exception if the term was created synthetically instead of being parsed, and no text was provided. name: returns string Abstract. Returns the name of the term. SEE ALSO
Mail::SPF, Mail::SPF::Record, Mail::SPF::Mech, Mail::SPF::Mod <http://tools.ietf.org/html/rfc4408> For availability, support, and license information, see the README file included with Mail::SPF. AUTHORS
Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org> perl v5.14.2 2012-01-30 Mail::SPF::Term(3pm)
All times are GMT -4. The time now is 08:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy