- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: perl equivalent of DCL search command
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
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
тАО02-11-2009 06:56 AM
тАО02-11-2009 06:56 AM
My company is switching from VAX to PC. The Windows search provides only the name of files containing the search string. I am VERY used to the DCL search feature of providing each line and the nearby lines (window) and would like to get the same capability on a PC.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-11-2009 07:28 AM
тАО02-11-2009 07:28 AM
SolutionI have a '\perl\bin\search.bat' that I _think_ came with the ActiveState perl distribution.
It is a perl script and does roughly what you want. It starts with:
## search
##
## Jeffrey Friedl (jfriedl@omron.co.jp), Dec 1994.
## Copyright 19.... ah hell, just take it.
##
## BLURB:
## A combo of find and grep -- more or less do a 'grep' on a whole
## directory tree. Fast, with lots of options. Much more powerful than
## the simple "find ... | xargs grep ....". Has a full man page.
## Powerfully customizable.
Personally, I often stick to the one-liners:
$ perl -le "print for (1000..4000)" > tmp.txt
$ perl -ne "$i=3 if /456/; print if $i-- > 0; print qq(\n) unless $i" tmp.txt
1456
1457
1458
2456
2457
2458
3456
3457
3458
I have also create several search algoritmes with pre-match and post-match output in perl and awk.. but the OpenVMS SEARCH/WIN is the best!
Google for "hein perl search" :-)
One example for a searching with a window...
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=630972
It is not too hard to add a file widlcard, but typically goes beyond one-liners:
$ perl -e "while ($f=shift) { open F,qq(<$f); while (
:
gbh.c 380 main(int argc, char *argv[])
getpos.c 12 int main(int argc, char *argv[]) {
getrmi.c 14 main(int argc, char *argv[])
:
Enjoy!
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-11-2009 08:04 AM
тАО02-11-2009 08:04 AM
Re: perl equivalent of DCL search command
Besides perl scripts, GNU grep or egrep will do
it as well with the -A,-B,-C,-NUM options.
Windows versions of these and other Unix utilities can be found at
http://unxutils.sourceforge.net/
Unix utilities are also part of the Cygwin suite for windows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-11-2009 08:22 AM
тАО02-11-2009 08:22 AM
Re: perl equivalent of DCL search command
ftp://ftp.cpan.org/pub/CPAN/authors/id/J/JF/JFRIEDL/jeffrey.perl.tar.gz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-11-2009 06:52 PM
тАО02-11-2009 06:52 PM
Re: perl equivalent of DCL search command
A much tighter and much less readily understood rewrite of the wildcard search:
Old:
$ perl -e "while ($f=shift) { open F,qq(<$f); while (
New:
$ perl -ne "close ARGV if eof; print qq($ARGV $. $_) if /main/" *.c
:-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-12-2009 03:43 AM
тАО02-12-2009 03:43 AM