Xref: utzoo comp.unix.questions:24117 comp.lang.perl:1909 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.unix.questions,comp.lang.perl Subject: Re: split afile into subiles with specific names Message-ID: <1990Jul27.190902.134@iwarp.intel.com> Date: 27 Jul 90 19:09:02 GMT References: <1990Jul27.182221.7202@cid.aes.doe.CA> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Distribution: na Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 30 In-Reply-To: afsipmh@cid.aes.doe.CA (Patrick Hertel) In article <1990Jul27.182221.7202@cid.aes.doe.CA>, afsipmh@cid (Patrick Hertel) writes: | | How would i go about doing the following (ed,sed,ex,vi,awk,perl even): | | Take a file something like this -> | | *DECK A | jcl | jcl | *DECK B | jcl | . | *DECK PAT | etc. | | .. and divide it up into files with names A, B, PAT (or whatever follows *DECK). This is the hard part, at laest for me because I am not fully UNIX literate | yet.. In Perl, it'd be: perl -ne 'if (/^\*DECK (.*)/) {open(STDOUT,">$1");} else {print;}' Yourfile You could probably do it with awk too. Maybe even Fortran. :-) Just another Perl hacker, -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/