Sponsored Content
Full Discussion: sed prepend text ?
Top Forums Shell Programming and Scripting sed prepend text ? Post 302696853 by upengan78 on Wednesday 5th of September 2012 02:20:38 PM
Old 09-05-2012
sed prepend text ?

Hi,

I have a file with email header information. I would like to change the Subject line.

Code:
Subject: ** PROBLEM Host Alert: server.domainname is DOWN **

I'd like to change this line such as to look,
Code:
Subject: serverID ACK Fw: ** PROBLEM Host Alert: server1.domainname is DOWN**

How can I edit this? sed or anything else is fine.

Note: server1.domainname, is not always constant it could be server2, server3.domainname up until server30.domainname
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

prepend columns to a file

I have two files. File 'a' has contents: 1|1 2|2 3|3 4|4 and file 'b' has contents: abc|def hij|klm nop|qrs tuv|wxy I would like to prepend file 'a' to file 'b' (with pipe) such that the contents of 'b' will be: 1|1|abc|def 2|2|hij|klm 3|3|nop|qrs 4|4|tuv|wxy (3 Replies)
Discussion started by: ChicagoBlues
3 Replies

2. Shell Programming and Scripting

Need to insert new text and change existing text in a file using SED

Hi all, I need to insert new text and change existing text in a file. For that I used the below line in the command line and got the expected output. sed '$a\ hi... ' shell > shell1 But I face problem when using the same in script. It is throwing the error as, sed: command garbled:... (4 Replies)
Discussion started by: iamgeethuj
4 Replies

3. Shell Programming and Scripting

Append and Prepend Text to a file list

I want to print out a directory listing, then append ] to the end of each line. I'm trying to create a list of Wiki links based on folder listings that i can just copy and paste without having to edit 100's of file listings. Using sed i've figured out to do something like this: sed... (4 Replies)
Discussion started by: CapnDoody
4 Replies

4. Shell Programming and Scripting

Help with uniq -D [prepend]

Hi, I am trying to add a blank line between sets of replicate values. I have been trying to use uniq -D -f4 input.txt > output.txt The input is like V2-1.0 -1.0 5500.00 4162.00 529976.06030125.0 1997A V2-1.0 -1.0 6000.00 4285.00 ... (6 Replies)
Discussion started by: eknryan
6 Replies

5. Shell Programming and Scripting

awk text record - prepend first field to all subsequent fields

Hello everyone, I've suddenly gotten very interested in sed and awk (and enjoying it quite a bit too) because of a large conversion project that we're working on. I'm currently stuck with a very inefficient process for processing text blocks. I'm sure someone here should be able to easily point out... (2 Replies)
Discussion started by: jameswatson3
2 Replies

6. Shell Programming and Scripting

How to prepend spaces using sed command..?

hi all , i had the below sed command to append header at the starting of my output file .... sed -i -e '1i saikumar suresh hemanth' output.txt i want to append spaces to the Name saikumar how can i append with in this command ....? (1 Reply)
Discussion started by: hemanthsaikumar
1 Replies

7. Shell Programming and Scripting

Prepend text, different matched 1st letters

Prepending lines with: your, the, a or an based on 1st letter match. You'll see my problem below: sed '/^p\|^f\|^c\|^d\|^l/ s/^/your /' list.txt > your.txt && sed '/^v\|^j\|^k\|^m\|^n\|^s/ s/^/the /' your.txt > the.txt && sed '/^b\|^g\|^h\|^q\|^r\|^t\|^w\|^z/ s/^/a /' the.txt > a.txt && sed... (10 Replies)
Discussion started by: p1ne
10 Replies

8. Shell Programming and Scripting

Gnu tool; sed awk echo etc to prepend or append string to a file

Looking to add text to a file, example File example; nodegroups: check-hosts: L@host.domain.com,host2.domain.com,host3.domain.com I need to take a file with a one line list of hosts separated by commas host.domain.com,host2.domain.com,host3.domain.comand prepend the string " ... (6 Replies)
Discussion started by: bash_in_my_head
6 Replies

9. UNIX for Beginners Questions & Answers

Prepend 0 to a field in a record

Hi All, I have a file like below. In the field 9 I am having 14,014,3,001/009 on the records. I want to convert the field to a three digit value. For example 14 should 014 , 3 should 003 11050;11001;;CREDITTRANC;5293218;NRATL;;;11095;;-1;14;3;29=0000;1.25... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies

10. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies
Mail::SpamAssassin::Message::Node(3)			User Contributed Perl Documentation		      Mail::SpamAssassin::Message::Node(3)

NAME
Mail::SpamAssassin::Message::Node - decode, render, and make available MIME message parts SYNOPSIS
DESCRIPTION
This module will encapsulate an email message and allow access to the various MIME message parts. PUBLIC METHODS
new() Generates an empty Node object and returns it. Typically only called by functions in Message. find_parts() Used to search the tree for specific MIME parts. An array of matching Node objects (pointers into the tree) is returned. The parameters that can be passed in are (in order, all scalars): Regexp - Used to match against each part's Content-Type header, specifically the type and not the rest of the header. ie: "Content- type: text/html; encoding=quoted-printable" has a type of "text/html". If no regexp is specified, find_parts() will return an empty array. Only_leaves - By default, find_parts() will return any part that matches the regexp, including multipart. If you only want to see leaves of the tree (ie: parts that aren't multipart), set this to true (1). Recursive - By default, when find_parts() finds a multipart which has parts underneath it, it will recurse through all sub-children. If set to 0, only look at the part and any direct children of the part. header() Stores and retrieves headers from a specific MIME part. The first parameter is the header name. If there is no other parameter, the header is retrieved. If there is a second parameter, the header is stored. Header names are case-insensitive and are stored in both raw and decoded form. Using header(), only the decoded form is retrievable. For retrieval, if header() is called in an array context, an array will be returned with each header entry in a different element. In a scalar context, the last specific header is returned. ie: If 'Subject' is specified as the header, and there are 2 Subject headers in a message, the last/bottom one in the message is returned in scalar context or both are returned in array context. raw_header() Retrieves the raw version of headers from a specific MIME part. The only parameter is the header name. Header names are case- insensitive. For retrieval, if raw_header() is called in an array context, an array will be returned with each header entry in a different element. In a scalar context, the last specific header is returned. ie: If 'Subject' is specified as the header, and there are 2 Subject headers in a message, the last/bottom one in the message is returned in scalar context or both are returned in array context. add_body_part() Adds a Node child object to the current node object. is_leaf() Returns true if the tree node in question is a leaf of the tree (ie: has no children of its own). Note: This function may return odd results unless the message has been mime parsed via _do_parse()! raw() Return a reference to the the raw array. Treat this as READ ONLY. decode() If necessary, decode the part text as base64 or quoted-printable. The decoded text will be returned as a scalar string. An optional length parameter can be passed in which limits how much decoded data is returned. If the scalar isn't needed, call with "0" as a parameter. rendered() render_text() takes the given text/* type MIME part, and attempts to render it into a text scalar. It will always render text/html, and will use a heuristic to determine if other text/* parts should be considered text/html. Two scalars are returned: the rendered type (either text/html or whatever the original type was), and the rendered text. set_rendered($text, $type) Set the rendered text and type for the given part. If type is not specified, and text is a defined value, a default of 'text/plain' is used. This can be used, for instance, to render non-text parts using plugins. visible_rendered() Render and return the visible text in this part. invisible_rendered() Render and return the invisible text in this part. content_summary() Returns an array of scalars describing the mime parts of the message. Note: This function requires that the message be parsed first! delete_header() Delete the specified header (decoded and raw) from the Node information. get_header() Retrieve a specific header. Will have a newline at the end and will be unfolded. The first parameter is the header name (case- insensitive), and the second parameter (optional) is whether or not to return the raw header. If get_header() is called in an array context, an array will be returned with each header entry in a different element. In a scalar context, the last specific header is returned. ie: If 'Subject' is specified as the header, and there are 2 Subject headers in a message, the last/bottom one in the message is returned in scalar context or both are returned in array context. Btw, returning the last header field (not the first) happens to be consistent with DKIM signatures, which search for and cover multiple header fields bottom-up according to the 'h' tag. Let's keep it this way. get_all_headers() Retrieve all headers. Each header will have a newline at the end and will be unfolded. The first parameter (optional) is whether or not to return the raw headers, and the second parameter (optional) is whether or not to include the mbox separator. If get_all_header() is called in an array context, an array will be returned with each header entry in a different element. In a scalar context, the headers are returned in a single scalar. perl v5.12.1 2010-03-16 Mail::SpamAssassin::Message::Node(3)
All times are GMT -4. The time now is 01:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy