03-05-2007
Problem to add the string(without sed & awk) into the middle of file
Hi,
I have tried many times to add the string into the first line of the file f1 or the middle of the file f1. This file f1 already consists of 10 numbers of lines 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 the midd of the file.
Thanks
kind regards,
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I would appreciate it if any one can guide me in using awk perhaps sed in extracting some values from a long string.
here is an example.
.......some lines here........
........ aaaa bbbb cccc ddddd eeeee fffff gggg (time:hhhh)........
......some lines here also..........
How can I extract... (2 Replies)
Discussion started by: odogbolu98
2 Replies
2. Shell Programming and Scripting
Hi,
I am new to using Sed. I have a file containg lines like the following:
INFORM----Test.pc:168:10/11/05 12:34:26 > some text goes here..
TRACE-----Test.pc:197:10/11/05 12:34:26 > some text goes here..
My requirement is to replace 10/11/05 12:34:26 with a string <RUNDATE> (including <... (4 Replies)
Discussion started by: Hema_M
4 Replies
3. Shell Programming and Scripting
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)
Discussion started by: ciroredz
6 Replies
4. Shell Programming and Scripting
Hello,
I am new to shell scripting. I want to optimize my one of the script.
I have one file and i want to remove selected zones for domains from that file.In this file i have almost 3500 zones for domains.Sample data for the file....
named.backup... (0 Replies)
Discussion started by: nrbhole
0 Replies
5. UNIX for Dummies Questions & Answers
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)
Discussion started by: Chiefos
15 Replies
6. Shell Programming and Scripting
Greetings.
I don't have experience programing scripts. I need to insert a string in a specific position of another string on another file (last.cfg), for example:
File last.cfg before using script:
login_interval=1800
lcs.machinename=client04
File last.cfg after using script:... (4 Replies)
Discussion started by: vanesuke
4 Replies
7. Shell Programming and Scripting
I have large number of data files, close to 300 files, lets say all files are same kind and have extension .dat , each file have mulitple lines in it.
There is a unique line in each file containing string 'SERVER'. Right after this line there is another line which contain a string 'DIGIT=0',... (4 Replies)
Discussion started by: sal_tx
4 Replies
8. Shell Programming and Scripting
Input:
qwertmyuiop
It should print "m".
What's the command to do this with sed? (6 Replies)
Discussion started by: cola
6 Replies
9. Shell Programming and Scripting
Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file:
</member>
<member>
<name>TransactionID</name>
<value><string>123456789123456</string></value>
</member>
<member>
<name>Number</name>
... (9 Replies)
Discussion started by: cozzin
9 Replies
10. Shell Programming and Scripting
I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: -->
cat comp.pkglist
Package list: nss-util-devel-3.28.4-1.el6_9.x86_64
Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies
LEARN ABOUT MOJAVE
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.18.2 2012-11-28 Mail::DKIM::TextWrap(3)