What is MIME type "text/x-sed"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

text/x-sed is a MIME type for scripts written for the sed stream editor.
It signals that a file contains a set of instructions used to transform text. These scripts provide commands for search, replace, and other text manipulations.
Files with sed commands are saved as plain text. Many editors can highlight the syntax to make them easier to read.
Users typically save these as SED files.
For more details on how sed works, visit the GNU sed manual.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: text/x-sed    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="text/x-sed">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'text/x-sed');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

What is the text/x-sed MIME type used for?

The text/x-sed MIME type identifies scripts written for the sed (stream editor) utility, typically saved with the .sed extension. These files contain plain text commands used for automated text transformations, such as finding and replacing strings within data streams or files.

How do I configure Apache to serve .sed files correctly?

You can map the extension to the MIME type by adding a directive to your .htaccess file or main configuration. Use the line AddType text/x-sed .sed to ensure Apache tells the client that the file contains sed commands.

Will a web browser execute a text/x-sed file?

No, web browsers do not have the capability to execute Unix stream editor scripts. If a browser encounters a file sent with text/x-sed, it will usually display the raw code as plain text or prompt the user to download the file to their computer.

Is it safe to open text/x-sed files?

Viewing the file in a text editor or browser is safe, as it is just plain text. However, you should exercise caution before running the script using the sed command line utility, as malicious scripts could modify or delete critical files on your system.

Can I use text/plain instead of text/x-sed?

Yes, serving these scripts as text/plain is a common and valid alternative. This ensures that the file renders immediately in all browsers without triggering a download, though it loses the semantic indication that the file contains specific sed syntax.

How do I open a .sed file on Windows?

Since text/x-sed files are plain text, you can view and edit them with any standard editor like Notepad, Notepad++, or VS Code. To actually run the script, you would need a Windows port of the sed utility or a subsystem like WSL (Windows Subsystem for Linux).

What does the 'x-' prefix mean in text/x-sed?

The x- prefix indicates that this is a non-standard or experimental MIME type not officially registered with the IANA. While not a standard, it is widely recognized by Linux systems and web servers to distinguish sed scripts from generic text files.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.