Article View: bit.listserv.xedit-l
Article #772Re: make a change in many files
From: Mark D. H. Miller
Date: Fri, 23 Oct 1992 00:05
Date: Fri, 23 Oct 1992 00:05
94 lines
5230 bytes
5230 bytes
On Thu, 22 Oct 1992 08:33:31 PDT Larry<0084P@NAVPGS> said:
>I know I've seen an exec that uses Xedit to make a specified change
>(c/string1/string2/ * * ) in all of a list of files. Anybody have such a
>thing?
Several solutions to this problem were posted to the list in March 92.
I was one of those who posted a solution then. It is reposted here.
This is not my own code, but I've used it for years and find it very
useful.
*------------------------------------------------*
Mark D. H. Miller (metrmdhm@suvm.syr.edu)
Syracuse University, Faculty Computing Services
Research Data Center { +1 315 443-1144 }
*------------------------------------------------*
------- previous post from 92/03/26 starts here ----------
There has been some discussion of running an xedit command
or an xedit command file against a list of files. A colleague
of mine wrote one which has been shared locally for many years.
While it doesn't do everything one might like, it does enough
to be genuinely useful. I use it regularly. With his
permission, it is included below along with a short companion
exec which it requires.
/*=================================================================*/
/* MULTXED Exec: run Xedit command on multiple files */
/* Nelson R. Pardee <acdnrp@suvm.acs.syr.edu> */
/* Syracuse University, 2/27/89 */
/* DEPENDS ON: ALTERED Exec */
/* */
/* Allows global execution of an XEDIT command on several files. */
/* The most obvious is a global change command, giving the */
/* capability of changing all occurrences of a phrase in several */
/* commands with the invocation of MULTXED. An ALL command is */
/* another common example. A save is performed if the file is */
/* altered, else not. */
/* */
/* Argument: same as for LISTFILE, specifying the files that */
/* will be used. will then query for the command to be executed */
/* (or quit to stop). */
/* */
/* MULTXED * EXEC D */
/* */
/* will then list all of the files <* EXEC D> and query what */
/* xedit command to execute on them, e.g., <C/OLD/NEW/ * *>. */
/* Multiple commands can be entered separated by a pound (#) */
/* sign. MULTXED defaults to CASE M I. */
/* */
/* XEDIT options, such as NOPROF may be supplied */
/* <MULTXED * EXEC (NOPROF> */
/*=================================================================*/
trace
'conwait';
nq=queued()
parse upper arg fn ft fm '(' opt
if fm='' then fm='A'; if ft='' then ft='*'
if fn='' then do
say '**NO FILE NAME SPECIFICATION- QUITTING'; exit 16
end
say 'FILE(S) SELECTED WILL BE:';
'catalog ' fn ft fm
'listfile ' fn ft fm ' ( stack fifo'
n=queued()-nq
do i=1 to n
pull x; fileid.i=x;
end;
say 'ENTER XEDIT COMMAND or QUIT (use # to separate commands):'
trace
do while ((queued()>nq) | comm='COMM')
'CP TERM LINEND OFF'; parse pull c; 'CP TERM LINEND ON'
x=substr(c,1,4); parse upper var x x
if x='' | x='QUIT' then exit 4
if comm='COMM' then comm=c; else comm=comm'#'c
end
do i=1 to n
queue 'CASE M I';queue 'q ring'; queue comm ; queue 'altered';
XEDIT fileid.i ' ( ' opt noprof
end
/* //////////// cut here //// cut here /////////////// */
/*==================================================================*/
/* ALTERED xedit: Check if file been altered, Call from XEDIT */
/* IF file has been altered, QUEUE on a FILE cmd Else a QUIT cmd */
/* Nelson R. Pardee, <acdnrp@suvm.acs.syr.edu> */
/* Syracuse University, 11/20/86 */
/*==================================================================*/
trace
'EXTRACT/ALT'
if alt.2>0 then queue 'FILE'; else queue 'QQUIT'
Technical Details
Message-ID:
<921022.135308.LCL.METRMDHM@SUVM.SYR.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!bu.edu!wupost!zaphod.mps.ohio-state.edu!darwin.sura.net!paladin.american.edu!auvm!SUVM.SYR.EDU!METRMDHMShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10c92b,25c1af93d2d07bb5 X-Google-Attributes: gid10c92b,public X-Google-ArrivalTime: 1992-10-22 17:51:30 PST Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!bu.edu!wupost!zaphod.mps.ohio-state.edu!darwin.sura.net!paladin.american.edu!auvm!SUVM.SYR.EDU!METRMDHM From: METRMDHM@SUVM.SYR.EDU (Mark D. H. Miller) Newsgroups: bit.listserv.xedit-l Subject: Re: make a change in many files Message-ID: <921022.135308.LCL.METRMDHM@SUVM.SYR.EDU> Date: 23 Oct 92 00:05:24 GMT Sender: VM System Editor List <XEDIT-L@UGA.BITNET> Organization: SYRACUSE UNIV RESEARCH DATA CENTER Lines: 94 Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU X-Acknowledge-To: <METRMDHM@SUVM.SYR.EDU> In-Reply-To: Message of Thu, 22 Oct 1992 08:33:31 PDT from <0084P@NAVPGS>