I need to add a new lines with certain data, to an existing file, every 5 lines in the file.
There is no way to find any distinct charater pattern so
I will have to do a line count and then insert the new line.
I think using awk or sed is what I need to do.
Any help is appreciated.
Kunder (2 Replies)
Hi,
I have tried many times to add the string into the first line of the file or the middle of the file but could not find the solution.
I first tried by
$echo "paki" >> file
This code only append paki string at the end of file "file" but how can i add this "paki" into the first line or... (5 Replies)
i want to add a string in a very top of a file without using VI or SED or AWK
this is what ive done:
(echo '0a'; echo 'LINE OF TEXT'; echo '.'; echo 'wq') | ed -s myfile
to add astrng right in the middle i could have count the lines of the file and just chenge the address.
... (6 Replies)
Can anyone help me pls? I want to add a text into the middle of file.
I've writtenthe following script
text to add="$1"
file="$2"
lines=$(wc -l $2)
half_lines=$(expr $lines / 2)
head -$half_lines $2 > temp
echo "text to add" >> temp
((half_lines=$half_lines + 1))
tail -$half_lines $2... (6 Replies)
I've got a configuration file that is filled with xml text statements for example:
<...../>
<...../>
<...../>
<data id="java-options" value="-server -Djava.security.policy..../>
<...../>
<...../>
<...../>
I want to write a korn shell script that will go to this specific line and add a... (2 Replies)
Hi,
I want to write a script that takes a file and a string as params and adds the string to the middle line of the file. Also, I want to output the results back to the original file passed without using temp files.
I am very much new to UNIX so this is all a little like black magic to me at... (15 Replies)
How can
grep G.*schema
give me the result: ${Gacntg_dt}""'"'
doesn't G.*schema say give me an unlimited number of characters between G and schema?
:confused: (3 Replies)
How would I print the word "and" between the words "FOO" and BAR" using sed? My file has three words in it FOO and BAR. I only want the word "and".
Thanks every one. (7 Replies)
Hi,
I'm currently working on a shell script to automate a backup check on oracle database. My requirement is to grep the words between two delimiters and pass on to a variable..
for ex I have following values in my log file...
(DB_NAME), (163.24 25), (16/02/10 23:40), (COMPLETED),
I want... (5 Replies)
This could be a really dummy question.
I have a log text file.
What unix command to extract line from specific string to another specific string.
Is it something similar to?:
more +/"string" file_name
Thanks (4 Replies)
Discussion started by: aku
4 Replies
LEARN ABOUT OSX
mail::dkim::textwrap
Mail::DKIM::TextWrap(3) User Contributed Perl Documentation Mail::DKIM::TextWrap(3)NAME
Mail::DKIM::TextWrap - text wrapping module written for use with DKIM
SYNOPSIS (FOR MAIL::DKIM USERS)
use Mail::DKIM::TextWrap;
Just add the above line to any program that uses Mail::DKIM::Signer and your signatures will automatically be wrapped to 72 characters.
SYNOPSIS (FOR OTHER USERS)
my $output = "";
my $tw = Mail::DKIM::TextWrap->new(
Margin => 10,
Output => $output,
);
$tw->add("Mary had a little lamb, whose fleece was white as snow.
");
$tw->finish;
print $output;
DESCRIPTION
This is a general-purpose text-wrapping module that I wrote because I had some specific needs with Mail::DKIM that none of the contemporary
text-wrapping modules offered.
Specifically, it offers the ability to change wrapping options in the middle of a paragraph. For instance, with a DKIM signature:
DKIM-Signature: a=rsa; c=simple; h=first:second:third:fourth;
b=Xr2mo2wmb1LZBwmEJElIPezal7wQQkRQ8WZtxpofkNmXTjXf8y2f0
the line-breaks can be inserted next to any of the colons of the h= tag, or any character of the b= tag. The way I implemented this was to
serialize the signature one element at a time, changing the text-wrapping options at the start and end of each tag.
TEXT WRAPPING OPTIONS
Text wrapping options can be specified when calling new(), or by simply changing the property as needed. For example, to change the number
of characters allowed per line:
$tw->{Margin} = 20;
Break
a regular expression matching characters where a line break can be inserted. Line breaks are inserted AFTER a matching substring. The
default is "/s/".
BreakBefore
a regular expression matching characters where a line break can be inserted. Line breaks are inserted BEFORE a matching substring.
Usually, you want to use Break, rather than BreakBefore. The default is "undef".
Margin
specifies how many characters to allow per line. The default is 72. If no place to line-break is found on a line, the line will extend
beyond this margin.
Separator
the text to insert when a linebreak is needed. The default is "
". If you want to set a following-line indent (e.g. all lines but the
first begin with four spaces), use something like "
".
Swallow
a regular expression matching characters that can be omitted when a line break occurs. For example, if you insert a line break between
two words, then you are replacing a "space" with the line break, so you are omitting the space. On the other hand, if you insert a line
break between two parts of a hyphenated word, then you are breaking at the hyphen, but you still want to display the hyphen. The
default is "/s/".
CONSTRUCTOR
new() - create a new text-wrapping object
my $tw = Mail::DKIM::TextWrap->new(
Output => $output,
%wrapping_options,
);
The text-wrapping object encapsulates the current options and the current state of the text stream. In addition to specifying text wrapping
options as described in the section above, the following options are recognized:
Output
a scalar reference, or a glob reference, to specify where the "wrapped" text gets output to. If not specified, the default of STDOUT is
used.
METHODS
add() - process some text that can be wrapped
$tw->add("Mary had a little lamb.
");
You can add() all the text at once, or add() the text in parts by calling add() multiple times.
finish() - call when no more text is to be added
$tw->finish;
Call this when finished adding text, so that any remaining text in TextWrap's buffers will be output.
flush() - output the current partial word, if any
$tw->flush;
Call this whenever changing TextWrap's parameters in the middle of a string of words. It explicitly allows a line-break at the current
position in the string, regardless of whether it matches the current break pattern.
perl v5.16.2 2010-02-28 Mail::DKIM::TextWrap(3)