Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

224
Vistas
How to sort data by the numbers in third column?

If I have a file consisting of data that looks as follows, how would I sort the data based on the numbers in the third column?

The spaces between the first two columns are not tab delimited, but some number of spaces. The space between the second and third column varies based on the size of the number.

Also note that there are spaces within some data of the second column (like lp25( plasmid between ( and p) while others do not have any spaces (like chromosome).

HELIX       lp25(plasmid           24437 bp    RNA     linear       29-AUG-2011
HELIX       cp9(plasmid             9586 bp    DNA     helix       29-AUG-2011
HELIX       lp28-1(plasmid         25455 bp    DNA     linear       29-AUG-2011
HELIX       chromosome            911724 bp    DNA     plasmid       29-AUG-2011
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Here you go:

sort -n -k 3 test.txt

From man sort:

-n, --numeric-sort          compare according to string numerical value
-k, --key=KEYDEF          sort via a key; KEYDEF gives location and type

KEYDEF is F[.C][OPTS][,F[.C][OPTS]] for start and stop position, where F is a field number and C a character position in the field; both are origin 1, and the stop position defaults to the line's end. If neither -t nor -b is in effect, characters in a field are counted from the beginning of the preceding whitespace. OPTS is one or more single-letter ordering options [bdfgiMhnRrV], which override global ordering options for that key. If no key is given, use the entire line as the key.

and also interesting:

-t, --field-separator=SEP use SEP instead of non-blank to blank transition

which tells us that the F fields are separated by whitespace.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda