split afile into subiles with specific names
Randal Schwartz
merlyn at iwarp.intel.com
Sat Jul 28 05:09:02 AEST 1990
In article <1990Jul27.182221.7202 at cid.aes.doe.CA>, afsipmh at 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 at iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
More information about the Comp.unix.questions
mailing list