Sponsored Content
Top Forums Shell Programming and Scripting Please suggest a script or solution? Post 28465 by Perderabo on Wednesday 18th of September 2002 07:50:49 PM
Old 09-18-2002
If I understand what you're asking, try this. This script does what I think you want done. Ai least, I think it does...
Code:
#! /usr/bin/ksh

##  r-r--s
##  r-r--t

longset="[acdefghiklmnpqrstvyz]"
pattern="r${longset}r${longset}${longset}[ts]"
typeset -u upshift

linen=0
IFS=""
while read input ; do
        orig=$input
        matches=0
        pos=1
        ((linen=linen+1))
        image=""
        while ((${#input})) ; do
                preamble="Line: ${linen} At position"
                if [[ $input = *(?)${pattern}*(?) ]] ; then
                        ((matches=matches+1))
                        leftover=${input#*${pattern}}
                        temp=${input%${leftover}}
                        lead=${temp%${pattern}}
                        this=${temp#${lead}}
                        upshift=${this}
                        input=$leftover
                        if ((${#lead})) ; then
                                echo $preamble $pos ${#lead} unmatched characters
                                image="${image}${lead}"
                                ((pos=pos+${#lead}))
                        fi
                        echo $preamble $pos MATCH: $this
                        image="${image}${upshift}"
                        ((pos=pos+${#this}))
                else
                        if ((matches)) ; then
                                echo $preamble $pos ${#input} trailing characters
                        fi
                        image="${image}${input}"
                        input=""
                fi
        done
        if ((matches)) ; then
                echo "$image"
                echo
                echo
        fi
done
exit 0

Put the lines to searched into a data file and run them against this script. Something like:
./thisscript < data.file
 

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
ppmtopj(1)						      General Commands Manual							ppmtopj(1)

NAME
ppmtopj - convert a portable pixmap to an HP PaintJet file SYNOPSIS
ppmtopj [-gamma val] [-xpos val] [-ypos val] [-back dark|lite] [-rle] [-center] [-render none|snap|bw|dither|diffuse|monodither|monodif- fuse|clusterdither|monoclusterdither] [ppmfile] DESCRIPTION
Reads a portable pixmap as input and converts it into a format suitable to be printed by an HP PaintJet printer. For best results, the input file should be in 8-color RGB form; i.e. it should have only the 8 binary combinations of full-on and full-off primaries. You could get this by sending the input file through ppmquant -map with a map file such as: P3 8 1 255 0 0 0 255 0 0 0 255 0 0 0 255 255 255 0 255 0 255 0 255 255 255 255 255 Or else you could use use ppmdither -red 2 -green 2 -blue 2. OPTIONS
-rle Run length encode the image. (This can result in larger images) -back Enhance the foreground by indicating if the background is light or dark compated to the foreground. -render alg Use an internal rendering algorithm (default dither). -gamma int Gamma correct the image using the integet parameter as a gamma (default 0). -center Center the image to an 8.5 by 11 page -xpos pos Move by pos pixels in the x direction. -ypos pos Move by pos pixels in the y direction. REFERENCES
HP PaintJet XL Color Graphics Printer User's Guide SEE ALSO
pnmdepth(1), ppmquant(1), ppmdither(1), ppm(5) BUGS
Most of the options have not been tested because of the price of the paper. AUTHOR
Copyright (C) 1991 by Christos Zoulas. 13 July 1991 ppmtopj(1)
All times are GMT -4. The time now is 02:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy