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

  • Home
  • SEARCH
  • 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 6700505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:49:22+00:00 2026-05-26T06:49:22+00:00

for example if we have in a variable named var a string 2.test 1.test

  • 0

for example if we have in a variable named “var”

a string “2.test 1.test 9.test”

i want it to be

1.test 2.test 9.test

I was trying to apply this command

    echo $var | sort -n

but the output isn’t correct because if for example I have

2.text
11.text

it will print

11.text 2.text which is wrong because 11>2

thanks

  • 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-05-26T06:49:22+00:00Added an answer on May 26, 2026 at 6:49 am

    sort works on lines, not words.

    For the example you’ve shown us, you’re sorting a single line of text. For example:

    $ echo 2.text 11.text 3.text | sort -n
    2.text 11.text 3.text
    

    But that’s inconsistent with the output you’ve shown us, so I can’t be sure just what you’re doing, or what you’re trying to do.

    Are you looking for something like this?

    $ echo 2.text 11.text 3.text | fmt -1
    2.text
    11.text
    3.text
    $ echo 2.text 11.text 3.text | fmt -1 | sort -n
    2.text
    3.text
    11.text
    

    And do you need to re-assemble the lines into a single line? Piping the output through fmt -999 will do that, but that’s a bit ugly (GNU coreutils fmt limits the width to 2500).

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

Sidebar

Related Questions

I have a string variable that represents the name of a custom class. Example:
I have string value and Type of some variable (For example int and 32
I have done urlencode of the variable before passing to the URL http://example.com/Restaurants?alias=F%26B But
I have this array, for example (the size is variable): x = [1.111, 1.122,
I have an website with URL`s like example.com/index.php?p=home An this script $(document).ready(function() { var
Question One I have var example : array[0..15] of char; I want to assign
I have JSON object inside variable like this: var chessPieces = { p-w-1 :
How can I update a variable outside of a function? For example I have
I need your help, For example I have a decimal type variable and I
I have a char variable, declared for example as: char a = 's'; How

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.