<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/output-record-separator-in-ruby-vxlh3eckp" -->

---
title: Output Record Separator in Ruby | daily.dev
description: Explains the meaning of Ruby's obscure $, (output field separator) and $\ (output record separator) global variables, sparked by a LinkedIn question about a...
canonical: https://daily.dev/posts/output-record-separator-in-ruby-vxlh3eckp
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Output Record Separator in Ruby | daily.dev
og:description: Explains the meaning of Ruby's obscure $, (output field separator) and $\ (output record separator) global variables, sparked by a LinkedIn question about a...
og:url: https://daily.dev/posts/output-record-separator-in-ruby-vxlh3eckp
og:image: https://api.daily.dev/og/posts/VxLh3eckp.png
og:image:alt: Output Record Separator in Ruby
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Output Record Separator in Ruby

**[RUBYLAND](https://daily.dev/sources/rubyla)** · 2 min read · 0 upvotes · 0 comments

## Summary

Explains the meaning of Ruby's obscure $, (output field separator) and $\ (output record separator) global variables, sparked by a LinkedIn question about a trailing comma spotted in the Rails source. The default nil value means no separator, but setting these variables lets you generate CSV-like output from the command line without requiring the CSV library. Notes that this mnemonic global variable is deprecated in Ruby 4.0, with the English module alias $OUTPUT_RECORD_SEPARATOR recommended instead for non-one-liner code.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://avdi.codes/output-record-separator-in-ruby>

## Questions this post answers

### What does the $, global variable mean in Ruby?

It is the output field separator, borrowed from Perl and AWK conventions, where comma is a common separator mnemonic. Its default value is nil, meaning no separator is inserted between values printed with methods like print. Setting it to a comma lets print output comma-separated values without requiring the CSV library.

_Developers puzzling over cryptic Ruby globals can find explainers like this through daily.dev._

### Is Ruby's $, global variable deprecated?

Yes, the mnemonic global variable $, (along with its counterpart $\, the output record separator) is deprecated starting in Ruby 4.0. The recommended replacement in non-one-liner code is the English module alias $OUTPUT_RECORD_SEPARATOR, which is more readable than the cryptic punctuation-based name.

_Ruby developers tracking upcoming 4.0 deprecations can follow changes like this on daily.dev._

### Why does Rails set sep to $, instead of nil in its source code?

Rails sets sep to the current global output record separator rather than hardcoding nil, so that the behavior complies with whatever separator convention a programmer has already configured via $,. Since $,'s default value is nil anyway, this preserves expected output formatting instead of overriding a developer's custom separator setting.

_Understanding quirky Rails source decisions like this helps developers debugging similar code via daily.dev._

## Similar posts on daily.dev

- [Pretty SQLite Output Persistently](https://daily.dev/posts/pretty-sqlite-output-persistently-sivyz9kzd) · RUBYLAND · 1 upvotes · 0 comments
- [The output must be cleaned \(with skill\)](https://daily.dev/posts/the-output-must-be-cleaned-with-skill--usa51bh9w) · thoughbot · 1 upvotes · 0 comments
- [your community gem host](https://daily.dev/posts/your-community-gem-host-vi4wnzc2b) · Ruby Flow · 0 upvotes · 0 comments
- [No tricks, just treats](https://daily.dev/posts/no-tricks-just-treats-ssvpluw7m) · Rails · 0 upvotes · 0 comments
- [A shell colon does nothing. Use it anyway](https://daily.dev/posts/a-shell-colon-does-nothing-use-it-anyway-iozfojz8n) · Lobsters · 0 upvotes · 0 comments

---

Tags: [#ruby](https://daily.dev/tags/ruby), [#rails](https://daily.dev/tags/rails)

[View this post on daily.dev](https://daily.dev/posts/output-record-separator-in-ruby-vxlh3eckp)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Output Record Separator in Ruby","url":"https://daily.dev/posts/output-record-separator-in-ruby-vxlh3eckp","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/output-record-separator-in-ruby-vxlh3eckp"},"datePublished":"2026-08-25T19:52:53.094Z","dateModified":"2026-08-25T21:44:17.732Z","description":"Explains the meaning of Ruby's obscure $, (output field separator) and $\\ (output record separator) global variables, sparked by a LinkedIn question about a...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/be0b915574603f0cc1134959733bb375?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/be0b915574603f0cc1134959733bb375?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"RUBYLAND","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"RUBYLAND","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/rubyla","url":"https://daily.dev/sources/rubyla"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/output-record-separator-in-ruby-vxlh3eckp","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ruby,rails","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"RUBYLAND","item":"https://daily.dev/sources/rubyla"},{"@type":"ListItem","position":3,"name":"Output Record Separator in Ruby"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/output-record-separator-in-ruby-vxlh3eckp#faq","mainEntity":[{"@type":"Question","name":"What does the $, global variable mean in Ruby?","acceptedAnswer":{"@type":"Answer","text":"It is the output field separator, borrowed from Perl and AWK conventions, where comma is a common separator mnemonic. Its default value is nil, meaning no separator is inserted between values printed with methods like print. Setting it to a comma lets print output comma-separated values without requiring the CSV library. Developers puzzling over cryptic Ruby globals can find explainers like this through daily.dev."}},{"@type":"Question","name":"Is Ruby's $, global variable deprecated?","acceptedAnswer":{"@type":"Answer","text":"Yes, the mnemonic global variable $, (along with its counterpart $\\, the output record separator) is deprecated starting in Ruby 4.0. The recommended replacement in non-one-liner code is the English module alias $OUTPUT_RECORD_SEPARATOR, which is more readable than the cryptic punctuation-based name. Ruby developers tracking upcoming 4.0 deprecations can follow changes like this on daily.dev."}},{"@type":"Question","name":"Why does Rails set sep to $, instead of nil in its source code?","acceptedAnswer":{"@type":"Answer","text":"Rails sets sep to the current global output record separator rather than hardcoding nil, so that the behavior complies with whatever separator convention a programmer has already configured via $,. Since $,'s default value is nil anyway, this preserves expected output formatting instead of overriding a developer's custom separator setting. Understanding quirky Rails source decisions like this helps developers debugging similar code via daily.dev."}}]}
```

