Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:40:50+00:00 2026-06-09T00:40:50+00:00

I have a plain text file where newline character in not \n but a

  • 0

I have a plain text file where newline character in not "\n" but a special character.

Now I want to sort this file.

Is there a direct way to specify custom new-line character while using unix sort command?
I don’t want to use a script for this as far as possible?

Please note the data in text file have \n, \r\n, and \t characters(the reason for such data is application specific so please don’t comment on that).

The sample data is as below:

1111\n1111<Ctrl+A>
2222\t2222<Ctrl+A>
3333333<Ctrl+A>

Here Ctrl+A is the newline character.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:40:51+00:00Added an answer on June 9, 2026 at 12:40 am

    Use perl -001e 'print sort <>' to do this:

    prompt$ cat -tv /tmp/a
    2222^I2222^A3333333^A1111
    1111^A
    
    prompt$ perl -001e 'print sort <>' /tmp/a | cat -tv    
    1111
    1111^A2222^I2222^A3333333^Aprompt$  
    

    That works because character 001 (octal 1) is control-A ("\cA"), which is your record terminator in this dataset.

    You can also use the code point in hex using -0xHHHHH. Note that it must be a single code point, not a string, using this shortcut. There are ways of doing it for strings and even regexes that involve infinitessimally more code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a text file that says: This file has plain text Now,
I have a plain text-file (.yml) that contains UTF-8 character sequences like this: foo:
I have a plain text file that looks like this - 234234 some text
I have a plain text file with this content: Test: \u0410\u0412\u0422\u041e I try to
I want to load a div which I have saved as plain text(file). I
I have a plain text file with a number of lines (new line character
I have an <iframe> whose src points to a plain text file (not HTML).
I have a plain text file looking like this: some text containing line breaks
Input: I have a LaTeX file, with plain text & math formulas. Desired output:
Suppose I have something like this: if ($command === 'txt') { header('Content-type: text/plain;charset=utf-8'); echo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.