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 7724575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:43:25+00:00 2026-06-01T04:43:25+00:00

I have a Perl script using a system call to sort a tsv file:

  • 0

I have a Perl script using a system call to sort a tsv file:

system("sort -k8 -r -n -t \$'\t' in.txt > out.txt");

It works fine in CentOS and SUSE Linux. But in Ubuntu, it gives an error:

sort: multi-character tab `$\t'

It seems the problem with different OS interpret the quote differently. Do you have a simple but more robust method to sort a tsv file in Perl?

  • 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-01T04:43:27+00:00Added an answer on June 1, 2026 at 4:43 am

    Usually, you’d use an array invocation of system to avoid the shell, but you have I/O redirection in the command, which is fiddly to deal with. OTOH, sort allows you to specify the output file with -o, and the named file could be one of the inputs (though it won’t be here):

    my @cmd = ( "sort", "-k8", "-rn", "-t", "\t", "-o", "out.txt", "in.txt" );
    
    system(@cmd);
    

    The shell is not invoked; the tab is not mangled. I combined the -r and -n options into one; you could leave them separate if you prefer, or (at a pinch) add them after the -k8 option.

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

Sidebar

Related Questions

I have a Perl/POE/Tk script running on Win32 ActivePerl that calls executables using system
I have a perl script which is using relative file paths. The relative paths
I am using a Windows System Command Prompt to call on a Perl Script.
I have a Perl script that I'm attempting to set up using Perl Threads
I have a Perl script where I maintain a very simple cache using a
I have a Perl script that I'd like to run on Windows, using either
I have a simple Perl script which runs as a Linux daemon using an
I have a Perl test script written using Test::More . Right before exiting, and
I have a perl script using the utf8 pragma, and for various reasons it
I have a perl script which calls another perl script using backticks. I want

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.