Sponsored Content
Top Forums Shell Programming and Scripting Please suggest a script or solution? Post 28516 by Optimus_P on Thursday 19th of September 2002 12:44:53 PM
Old 09-19-2002
Code:
#!/usr/bin/perl -w

while (<>) {
        chomp;

        if ($_ =~ /(r[acdefghiklmnpqrstvyz]r.{2}[st])/ ) {      # see if the current line matches what we are looking for.
                $found = index($_,$1);  # if we find a match find out how many positions over in the line the match is
                write (STDOUT);         # print out the report.
        }
}



format STDOUT =
@<<<<< @<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$.,($found+6),(s/(r[acdefghiklmnpqrstvyz]r.{2}[st])/\U$1/g)
              ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$_
              ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$_
+-----------------------------+
.

format STDOUT_TOP =
+=================================+
|COOL STUFF BY OPTIMUSP at UNIXCOM|
+=================================+
Line Position Text
==== ======== ====
.

Code:
MY TEST DATA
mwaaagglwrsraragtlralfrsrdaalfpgcerglhcstrarjxsatacsavswlkkfaslgshstykpskleflmrstskktrkedharlralngll
ykaltdllctpevsqelydlnvelskvsltpdfsacraywkttlsaeqnahmeavlqrsaahmslisywqsqtldpgmkettlykmisgtlmphnpaapq
srpqapvcvgsimrrstsrlwstkggkikgsgawcgrgrwls

so far this is the base code. the only thing left is something to iterate thru the line to see if there is more then 1 match. but then again. if you have at least 1 match you can study that line a bit more. for a final inspection.

Last edited by Optimus_P; 09-19-2002 at 04:46 PM..
 

5 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to get the script corrected to get the solution

Can anyone help it out, My Requirement: Actually i grep for the items in the atrblist (Result of it will provide the line where the item present and also the next line of where it presents)then it will be stored in $i.txt From tat result i wil grep 2nd word after getdate() word and store... (2 Replies)
Discussion started by: prsam
2 Replies

2. Shell Programming and Scripting

Perl script solution

Hi I need to do this thing in awk (or perl?). I try to find out how can I identify 1st and 2nd result from the OR expression in gensub: block='title Sata Mandriva kernel /boot/vmlinuz initrd /boot/initrd.img' echo "$block" | awk '{ x=gensub(/(kernel|initrd) /,"\\1XXX","g"); print x }' ... (12 Replies)
Discussion started by: webhope
12 Replies

3. UNIX for Advanced & Expert Users

Solution required for awk script

Hi Jim, The following script is in working state. But i m having one more problem with awk cmd. Could you tell me how to use any variable inside awk or how to take any variable value outside awk. My problem is i want to maintain one property file in which i am declaring variable value into that... (1 Reply)
Discussion started by: Ganesh Khandare
1 Replies

4. Shell Programming and Scripting

Please suggest the Sites for perl script beginners for better understanding

I am begginer to perl scripting, i like to learn all the functionality of the perl scrpting , Could you please help me on this :confused::confused: (2 Replies)
Discussion started by: jothi basu
2 Replies

5. Shell Programming and Scripting

Script solution as singleline ?

Hello My script has following line and output find path -type d | awk -F "/" 'NF == 4{print $3}' path/custype=Type1/logdate=20160414 path/custype=Type11122/logdate=20160414 But I need following output that I need custtype information between "" like... (4 Replies)
Discussion started by: msuluhan
4 Replies
IO::Pager::Page(3)					User Contributed Perl Documentation					IO::Pager::Page(3)

NAME
IO::Pager::Page - Emulate IO::Page, pipe STDOUT to a pager if STDOUT is a TTY SYNOPSIS
Pipes STDOUT to a pager if STDOUT is a TTY DESCRIPTION
IO::Pager was designed to programmatically decide whether or not to point the STDOUT file handle into a pipe to program specified in the PAGER environment variable or one of a standard list of pagers. USAGE
BEGIN { use IO::Pager::Page; # use I::P::P first, just in case another module sends output to STDOUT } print<<HEREDOC; ... A bunch of text later HEREDOC If you wish to forgo the potential for a Broken Pipe foible resulting from the user exiting the pager prematurely, load IO::Pager::Page like so: use IO::Pager::Page hush=>1; SEE ALSO
IO::Page, IO::Pager, IO::Pager::Unbuffered, IO::Pager::Buffered AUTHOR
Jerrad Pierce <jpierce@cpan.org> Florent Angly <florent.angly@gmail.com> This module inspired by Monte Mitzelfelt's IO::Page 0.02 COPYRIGHT AND LICENSE
Copyright (C) 2003-2012 Jerrad Pierce o Thou shalt not claim ownership of unmodified materials. o Thou shalt not claim whole ownership of modified materials. o Thou shalt grant the indemnity of the provider of materials. o Thou shalt use and dispense freely without other restrictions. Or, if you prefer: This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.0 or, at your option, any later version of Perl 5 you may have available. perl v5.16.2 2012-09-04 IO::Pager::Page(3)
All times are GMT -4. The time now is 10:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy