Operating System - OpenVMS
1756310 Members
3425 Online
108844 Solutions
New Discussion юеВ

Begining of lline search

 
Madhu Mohan
New Member

Begining of lline search

Hello,

Can anyone please update me in OpenVMS how to do a begining/start of line search , somthing like 'grep ^text' which searches for 'text' at the begining of line in unix.
8 REPLIES 8
Jan van den Ende
Honored Contributor

Re: Begining of lline search

Madhu Mohan,

To begin: WELCOME to the VMS Forum!

Your question immediate leads to another:

WHICH VERSION of OpenVMS?

Recent versions DO have something similar to this capability...

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Joseph Huber_1
Honored Contributor

Re: Begining of lline search

Get GNV , it contains grep and many other GNU utilities.
http://h71000.www7.hp.com/opensource/gnv.html
http://www.mpp.mpg.de/~huber
Hein van den Heuvel
Honored Contributor

Re: Begining of lline search


Standard OpenVMS search does not have this.

Just use gnu/gnv grep, awk or perl to do this, on OpenVMS.

$ perl -ne "print if /^text/" x.x

(Un)fortunately perl opens (input) files exclusively.
So if you need to search a live (log) file, then you need an explicit open such as:

$fh = vmsopen( $file, qw( shr=put mbc=112 mbf=4))

Good luck!
Hein
labadie_1
Honored Contributor

Re: Begining of lline search

If you are on Openvms Alpha, you can do it on a standard VMS box, just define a symbol awk

$ awk :== $SYS$COMMON[SYSHLP.EXAMPLES.TCPIP.SNMP]GAWK.EXE

and then you can do

$ ty test.tmp
Port123
ABC Port

$ ty bb.awk
/^Port/ { print }

$ awk/input=bb.awk test.tmp
Port123

Hoff
Honored Contributor

Re: Begining of lline search

The VMS search mechanisms are weak and exceedingly slow, and the operating system lacks regex support.

If you're willing to run with a slow search (and akin to the VMS SEARCH command), then use grep available via the GNV tools, or one of the available add-on grep or egrep tools.

Or load and use perl or other such, which have similar (low) performance.

Or roll your own DCL loop to do this stuff.

Or (if you're finding yourself doing more of these searches) then remote-mount the disk structure or replicate the disk structure, and index it, and search it from a box that has indexing and search capabilities.

Steven Schweda
Honored Contributor

Re: Begining of lline search

Since about 6-JUL-1999, I've used a (crude
spelling-advice) command procedure which does
something like the following. (Note that
"/format = nonulls" would be unnecessary for
a typical input file, but this example file
is atypical.)

Too simple:

alp $ search /format = nonulls -
sys$library:vms$password_dictionary.data searche
researcher
researchers
researches
searched
searches

Better:

alp $ search /format = nonulls -
sys$library:vms$password_dictionary.data searche -
/key = (pos = 1, siz = 'f$length( "searche")')
searched
searches

Of course, a working "grep" might be easier.

(The spelling advice would be better if that
word list didn't contain so many misspelled
words, but it is cheap and available.)
Graham Burley
Frequent Advisor

Re: Begining of lline search

Depends on your OpenVMS version, either:

$ search somefile text*/wild=strict

or

$ search somefile text/key=(pos:1,siz:4)
Ian Miller.
Honored Contributor

Re: Begining of lline search

I use FIND which appeared on Freeware V6
e.g
http://digiater.com/openvms/freeware/v60/find015/

____________________
Purely Personal Opinion