- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: search for a specific string
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2006 02:20 AM
тАО10-05-2006 02:20 AM
I have OpenVMS 7.3-2
My question:
I want to read a person's name from the file header.
My approach:
I do a simple search command
$search File.EXT "Name" /out=Name.txt
It's fine but what this gives me (obviously) is the the entire line
Name: BOBBY DING DDSDFD SDDFSD
Now what I need is Bobby Ding from this, the distance between the ":" and B is always 18 so for any of the files the name always starts after 18 character space but the end varies
So my question is can we get just the name
Bobby Ding in a symbol eg
alpha := Bobby Ding
Let me know your thoughts and comments
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2006 02:24 AM
тАО10-05-2006 02:24 AM
Solutionhttp://h71000.www7.hp.com/freeware/freeware80/extract/
Purely Personal Opinion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2006 02:38 AM
тАО10-05-2006 02:38 AM
Re: search for a specific string
Read up topic 876934
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=876934
And learn perl !
$ perl -ne "if (/^Name:\s+(\w+\s+\w+)/){ $ENV{NAME}=$1; last }" tmp.tmp
$ show log name
"NAME" = "BOBBY DING" (LNM$PROCESS_TABLE)
If you don't care about first vs last match then:
$ perl -ne "$ENV{NAME}=$1 if /^Name:\s+(\w+\s+\w+)/" tmp.tmp
As 'bonus' the regexpr will only trigger on lines that start with the "Name". That may help. Drop the "^" if Name: can float on the line. Or use /^\s*name\s*:\s+(\w+\s+\w+)/i
That insists name is the first word on a line and must be followed by a colon, but allows for any whitespace and any case.
Enjoy,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2006 03:04 AM
тАО10-05-2006 03:04 AM
Re: search for a specific string
And just because I wanted to know how hard a pipe solution would really be:
$ pipe sea tmp.tmp "Name:" | (read sys$pipe x ; y=f$ed(x,"COMPRESS") ; s=" " ; x=f$el(1,s,y)+s+f$el(2,s,y) ; def/job x &x)
$
$ show log x
"X" = "BOBBY DING" (LNM$JOB_819E9000)
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2006 05:44 AM
тАО10-06-2006 05:44 AM
Re: search for a specific string
In the following example, I use Hein's Perl code verbatim, but before running it I tell Perl to use DCL symbols rather than logical names for its built-in %ENV hash:
$ define PERL_ENV_TABLES CLISYM_GLOBAL
$ perl -ne "if (/^Name:\s+(\w+\s+\w+)/){ $ENV{NAME}=$1; last }" tmp.tmp
$ show symbol name
NAME == "BOBBY DING"
If you want local symbols rather than global, use CLISYM_LOCAL as the value of PERL_ENV_TABLES.
Or here's a little hack that uses the VMS::DCLsym extension that's been included with every Perl distribution of the last 10 years or so (and in this example bypasses the documented tied hash inteface and directly uses the internal _setsym method rather than setsym):
$ perl -"MVMS::DCLsym" -ne -
_$ "if (/^Name:\s+(\w+\s+\w+)/){ VMS::DCLsym::_setsym('NAME',$1,'GLOBAL'); last }" tmp.tmp
$ show symbol name
NAME == "BOBBY DING"