MED(1NCARG)
β¨ NAME β¨
okay so like, welcome to MED(1NCARG) bestie π this is the page for med β the NCAR CGM metafile frame editor. yes the manual name is MED(1NCARG) and the section is NCAR GRAPHICS, we're not gonna make a whole thing of it, it's just the vibe ok π
πΈ SYNOPSIS πΈ
med [ -e command ]* [ -f sfilename ] [ -l local_dir ] [ -V ] [ filename]
that's it. that's the whole shape of it. no cap π
π¦ DESCRIPTION π¦
med is a frame-level, metafile editor and the whole design brief was basically "make it look syntactically like UNIX's sed(1) and ed(1)" β so if you already fw those, you're gonna be so cozy here, fr fr.
Here's the tea: med works on a copy of filename, and that copy is called a buffer. It only overwrites a file when you actually issue the w (write) command. That's the whole safety situation, she's careful π.
med gives you line oriented editing commands so you can:
- display or delete frames from the buffer
- move, copy or merge frames within the buffer
- write frames from and read frames into the buffer
And by default? med reads in commands from standard input. iconic behavior honestly π
π OPTIONS π
-e commandβ command is a singlemedcommand. (All the valid ones are gossiped about down in the Commands section, keep scrolling bestie π.) You can stack multiple-eoptions on a single command line β she's flexible like that. Be careful to use quotes if your command contains spaces or metacharacters that might be interpreted by the shell, ok?? protect your peace π. When this option is used,meddoes not enter interactive mode. It just does the given commands and then dips. periodt.-f sfilenameβ Execute themedline-separated list of commands in the file sfilename. After the commands are exhausted,medwill exit. bye π-l local_dirβ Use local_dir as the tmp directory for scratch disk space. If you don't specify this option,medwill use the value of the$NCARG_TMPor the$TMPDIRenvironment variable. Seencargintro(1ncarg)for a discussion on NCAR Graphics environment variables. go read it, i'll wait π-Vβ Print the version number and then exit. short, sweet, slays β¨
π USAGE π
π Command Structure π
med commands attempt to have a syntactically identical form to those of ed(1) or sed(1). So a command is made of an optional address, or two optional comma separated addresses, followed by a command (which may be abbreviated), and possibly followed by a third address or a command specific argument list:
[ address [, address ] ] command [ address | args ]
Here's how the addresses behave:
- one address β operations are performed on that frame.
- two addresses β
medperforms the operation on the inclusive range of frames. - no address β the current frame is used as a default.
the exception to all of that?? thew(write) and thea(append) commands. the default address forwis the entire buffer. she's built different π
Some examples so it clicks:
1,10pmeans "print (display) frame 1 through 10" β that's two addresses.dmeans "delete the current frame" β no address implies the current frame used as default.1,5c5means "append a copy of frames 1 through 5 at frame 5" β that's three addresses, main character energy β¨.
The meaning of argument varies for each operation. In med's current state the only valid argument is a filename β for the write, w, command for instance, argument is the name of the file to write to.
Unlike its friends ed(1) and sed(1), med attempts to be fairly user friendly π₯Ί. If an invalid or ambiguous command is given, med will tell you so. If med thinks it recognizes a command with invalid arguments, a usage statement for the offending command is given. If a particular command fails and med is smart enough to figure out why, it will tell you. med will almost ALWAYS immediately terminate when an error occurs while processing commands from a file or the command line β so like, no pressure but also some pressure π.
Help is available by using the h command. Usage statements for a particular command may be obtained with: h command name .
π« Addresses π«
Frames can be addressed in several ways:
nnnβ By frame number. Frames in the buffer are numbered relative to the start of the buffer. The first frame is frame1.$β The last frame of the buffer..β The current frame.medkeeps track of the frame on which you last performed an operation. This frame is called the current frame. You can address this frame by typing a "dot" character.Β±nβ By relative frame number. Address the frame number that is n frames higher, or n frames lower than the current frame.addressΒ±nβ An address followed by a plus sign (+) or a minus sign (-), followed by a decimal number, specifies that address plus or minus the indicated number of frames. If the address is omitted, the current frame is used as the base. For example,31-3addresses frame 28 in the buffer. math girlies rise π§
If you do not specify an address for a command to operate on, a command that requires an address supplies one by default, usually the current frame.
A pair of addresses separated by a comma signifies an inclusive range of frames, and the current frame is not changed unless the command changes it.
π Commands π
Only one command may appear per line. Commands may accept zero, one or two addresses, followed by possibly a third address or an argument. Commands that accept up to two addresses regard a third as an error. Likewise, commands that do not accept an argument regard one as an error. Commands may be abbreviated.
In the absence of a second address for a two or three address command, the command will regard the second address as the same as the first. For example, 2d is equivalent to 2,2d. The absence of a first address, where required, will result in the current frame being used as the default. The same is true in the absence of a required third address. For example, c is equivalent to .,.c..
The commands q (quit) and e (edit) may be followed by a '!' to override med's user protection. (she's protecting you, but sometimes you gotta be free π¦)
In the following list of med commands, the default addresses/arguments appear in parentheses; the parenthesized addresses are not part of the command. Unless otherwise noted, a command does not change the current frame number.
(1,$)append metafileβ Append buffer to a file. Append the addressed frames in the buffer to metafile. If no address is specified the entire buffer is written. If the file does not exist, create it.(.,.) copy (.)β Copy frames. Duplicate the addressed frames in the buffer and append them after the third address. The current frame becomes the destination of the last frame copied.(.,.)deleteβ Delete the addressed lines from the buffer.deleteaccepts one or two addresses; the default is the current frame. The current frame is set to the first frame after the deleted frame(s).edit metafileβ Edit a metafile. The current contents of the buffer, if any, are erased. The named metafile is read in to the buffer. The resulting current frame is the last frame in the buffer. If changes have been made to the buffer since the last write,medwill refuse the request unless the command is appended with a'!'.editprints the number of frames in the metafile. If no metafile is given, the current metafile, if any, is used. The current frame becomes the last frame in the file.help commandβ help. Give a usage message for command. If no command is given, print a list of command names with a short description of each.(.,.)label stringβ Label the addressed frames with string. The CGM Begin Picture element contained in each metafile frame allows for the encoding of character data.labelprovides a means for accessing this data.(.,.)mergeβ Merge the contents of the second addressed frame on top of the first addressed frame. The first addressed frame is thus changed. The second frame remains the same. The current frame is set to the first addressed frame.(.,.) move (.)β Move the addressed frames to the first frame following the third address.(.,.)printβ Show the contents of the buffer at the given address. What is actually displayed is information regarding the addressed frames. This information includes: relative frame number within the buffer, the number of records contained in the frame, the starting record for the frame and the contents of the CGM elementBEGIN PICTURE. If no address is specified the current frame does not change. Otherwise it becomes the last frame printed.quitβ Quit. Terminate the editing session without saving the buffer contents. In order to save the buffer an explicit write must be performed. If changes to the buffer have been made since the last write,medwill refuse to terminate unlessquitis appended with a'!'.(.)read metafileβ Read in a metafile. Read the contents of metafile into the buffer and append it at the given address. metafile must be a valid NCAR CGM. The resulting current frame is the last frame read in.(1,$)split<number> outfileβ Split the current metafile into number files. Thesplitcommand attempts to create number metafiles from the addressed frames, each containing approximately n / number frames where'n'is the total number of addressed frames. The first file is namedoutfile001.ncgm, the second file is namedoutfile002.ncgm, and so on lexicographically. If no outfile is given,medis used as the default (output files will be calledmed001.ncgm,med002.ncgm, etc.). organized queen π(1,$)write metafileβ Write buffer. Write the addressed frames in the buffer to metafile. If no address is specified the entire buffer is written. If the file does not exist, create it. If no file name is specified,meduses the last currently remembered file name, if any. The currently remembered file name is the file name from the most recenteditcommand, or the file namemedwas invoked with if noeditcommands have been issued.! commandβ Escape to the shell and execute command. command is a valid UNIX command. she said "i'm leaving" and she MEANT it π
π± ENVIRONMENT π±
NCARG_TMPβ If set, this environment variable contains a directory path to be used for temporary files. On most systems the default is/tmp.
π FILES π
/tmp/cgm_tools.#β temporary;#is the process id.
π EXAMPLES π
To concatenate the files ncgm1, ncgm2, and ncgm3 into a single file ncgm123 one might use the following:
% med -e 'r ncgm1' -e 'r ncgm2' -e 'r ncgm3' -e 'w ncgm123'
Or one could pass the following script to med as a -fscriptfile option or enter the commands interactively.
r ncgm1
r ncgm2
r ncgm3
w ncgm123
To Overlay the contents of frame 5 on top of frame 4 from a file ncgm1 one could execute:
% med -e '4,5 me' -e 'w!' ncgm1
π₯ SEE ALSO π₯
cgm(5NCARG)ed(1)sed(1V)
Hardcopy: NCAR Graphics Fundamentals, UNIX Version
π BUGS π
med does not understand filenames that begin with a digit or a period. so like, name your files accordingly bestie, she simply will not perceive them π
π CAVEATS π (aka the plot twists, bestie, read this part fr fr)
Okay so listen up because this is the part where I hold your hand and tell you the truth: the append, read and merge commands may produce surprising results. π Not like a cute little surprise. Like a "why does my plot look like that" surprise.
Here's the tea π β a CGM may contain a set of global graphical primitive attributes that are applied to every frame in a file. So when you read frames in from a file that has different global attributes than the current working file, you may not get the effect you wanted. The vibe check fails. It's giving chaos. π
Same energy when you append frames to a previously existing file β the attributes you're carrying in don't magically match up with what's already there, and the result might not be the serve you were going for. π
And it gets deeper, because the CGM standard itself specifies that graphical attributes specified within a metafile frame affect all succeeding primitives. So a frame that is the product of the merge command may appear differently than expected. β¨ Not a bug, not a glitch β just the standard doing standard things and your frame catching strays.
tl;dr: attributes are sticky and they travel. Don't be shocked when your merged or appended frame doesn't look like the mood board. π
π COPYRIGHT π
Like, the legal arc of this story, and yes we're doing it, because respect is respect. π«Ά
Copyright (C) 1987-2009 University Corporation for Atmospheric Research
The use of this Software is governed by a License Agreement.
And that's the whole page, bestie!! π You read a manual page and you understood it, main character behavior honestly. This was NCARG β MED(1NCARG) β dated January 1993, out here aging like fine wine while still telling you exactly which frame is which. π¦ Sending you good vibes and non-global attributes. Mwah. π
π¦ where this page comes from
- debian bookworm: ncl-ncarg 6.6.2.dfsg.1-1
- debian trixie: ncl-ncarg 6.6.2.dfsg.1-10+b2
- ubuntu jammy: ncl-ncarg 6.6.2-10build2
- ubuntu questing: ncl-ncarg 6.6.2.dfsg.1-10build2
- ubuntu resolute: ncl-ncarg 6.6.2.dfsg.1-12
- ubuntu stonking: ncl-ncarg 6.6.2.dfsg.1-12build2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms