how can i modify a file using sed when searching
for a pattern and insert newline after the pattern?
pattern example: $ ...(any characters)...$
$ may082001.../tmp/msg.001,,$ REPT CLEAR ALARMS ON UNIT 1
$ may082001.../tmp/msg.002,,$ UNIT 1 IN SERVICE
into:
$... (1 Reply)
Hi Every One...
I wanted to inserted a line in between matched pattrens..
Ex...
InPut File..
WRITEQ
TS
**************************
aaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbb
cccccccccccccccccccccccc
SOME PATTREN's
RESP ( WS-RESP )
... (7 Replies)
Alright, I think I know what I am doing with sed(which probably means I don't). But I cant figure out how to replace just the first occurance of a string. I have tried sed, ed, and grep but can't seem to figure it out. If you have any suggestions I am open to anything! (3 Replies)
I have a big database log file which keepsgrowing daily. OS is HP UX. Here is a small part of it:
Tue Jan 27 04:03:22 2009
: add session begin for mfgeb on /dev/pts/th.
: Converting relative path to absolute path.
: add session end.
Tue Jan 27 04:03:29... (6 Replies)
Hi,, Please excuse my lack of knowledge here. I think I am tring to do something fairly advanced yet am a bit of a beginner.....
I want to use a korn shell (as is the norm with others in my company) to write a script to search a file for a string and insert some text above that line.
Sudo... (5 Replies)
Hi
I'm trying to search for the last instance of the word 'cache' in a HTML file that I have downloaded from YouTube.
I'm using the following syntax, but an error is thrown when I try it.
grep -f "cache"
Also I wish to append the above grep command to the below so that the search for cache... (3 Replies)
I need to reduce a file's size below 50MB by deleting chucks of text. The following sed does this.
sed '/^begpattern/,/endpattern/d' myfile
However, it's possible that the file size can get below 50MB by just deleting the first instance of the pattern. How do I code that into sed?
Or can awk... (8 Replies)
I need to be able to search for a beginning line header, then use grep or something else to get the very next instance of a particular string, which will ALWAYS be in "Line5". What I have is some data that appears like this:
Line1
Line2
Line3
Line4
Line5
Line6
Line7
Line1
Line2
...... (4 Replies)
Hi All
I got one problem and want your help,what i want to do is
Input
123 key0=A;B;C;:key1=X;Y;Z;:
here 123 is a username
I should search the username (in this case it is 123) in file and if found it should insert the additional string D as below
Here 123 and key are tab seperated
... (6 Replies)
I have a following file:
# User defined in group
admin = boss, sysadmin
phpteam = php1, php2, php3
rubyteam = ruby1, ruby2
# SVN root should only be access by boss and system admin
@admin = rw
* =
# Main web repository should only be access by boss and system admin, others... (3 Replies)
Discussion started by: ankur328
3 Replies
LEARN ABOUT DEBIAN
perl::critic::policy::modules::requireversionvar
Perl::Critic::Policy::Modules::RequireVersionVar(3pm) User Contributed Perl Documentation Perl::Critic::Policy::Modules::RequireVersionVar(3pm)NAME
Perl::Critic::Policy::Modules::RequireVersionVar - Give every module a "$VERSION" number.
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
Every Perl file (modules, libraries, and programs) should have a package-scoped $VERSION variable. The $VERSION allows clients to insist
on a particular revision of your file like this:
use SomeModule 2.4; #Only loads version 2.4
This Policy scans your file for any package variable named $VERSION. I'm assuming that you are using "strict", so you'll have to declare
it like one of these:
our $VERSION = 1.0611;
$MyPackage::VERSION = 1.061;
use vars qw($VERSION);
use version; our $VERSION = qv(1.0611);
Perl's version system does not recognize lexical variables such as
my $VERSION = 1.0611;
so they are not accepted by this policy.
A common practice is to use the "$Revision: 4106 $" keyword to automatically define the $VERSION variable like this:
our ($VERSION) = '$Revision: 4106 $' =~ m{ $Revision: s+ (S+) }x;
CONFIGURATION
This Policy is not configurable except for the standard options.
NOTES
Conway recommends using the "version" pragma instead of raw numbers or 'v-strings.' However, this Policy only insists that the $VERSION be
defined somehow. I may try to extend this in the future.
TO DO
Add check that $VERSION is independently evaluatable. In particular, prohibit this:
our $VERSION = $Other::Module::VERSION;
This doesn't work because PAUSE and other tools literally copy your version declaration out of your module and evaluates it in isolation,
at which point there's nothing in "Other::Module", and so the $VERSION is undefined.
AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module.
perl v5.14.2 2012-06-07 Perl::Critic::Policy::Modules::RequireVersionVar(3pm)