Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Sorting one column underneath another Post 302888297 by newbie2010 on Thursday 13th of February 2014 05:07:33 PM
Old 02-13-2014
Sorting one column underneath another

I am trying to arrange these columns so that they look like this:

Code:
Xray2_1255555  Number of Copies: 1
Boxcar_1387305895  Number of Copies: 2
Fox_1387305896  Number of Copies: 2

But I have one column after another like this:
Code:
Xray2_1255555
Number of Copies:  1
Xray2_12444444
Number of Copies:  2
Boxcar_1387305895
Number of Copies:  2
Fox_1387305896
Number of Copies:  2
Red_1387305897
Number of Copies:  2
Horse_1387305933
Number of Copies:  2
Cow_1387306099
Number of Copies:  2
Rabbit_1387306148
Number of Copies:  2
Duck_1387306433
Number of Copies:  2
Elephant_1387306638
Number of Copies:  2
squirrel_1387306802

I've tried
Code:
cat /tmp/file |xargs

Code:
cat /tmp/file|awk '{(printf%s, $0)}'

I've also tried the paste command without luck. What is the best way to do this? If I use paste or awk the columns are horizontal but get skewed across the screen. I want the "Number of Copies to form a second column after the name "Xray2_1244444 etc."

Last edited by Don Cragun; 02-14-2014 at 05:50 PM.. Reason: Add more CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sorting a column in this scenario

Hi, I need to sort the 3rd column in ascending order , each and every column are seperated by ~. sample input file : 2~Lead Time Metrics~jennife1 2~Lead Time Metrics~mmullis 2~Lead Time Metrics~lisah 2~Lead Time Metrics~pros 2~Lead Time Metrics~kenward can any one help me out . i... (1 Reply)
Discussion started by: krishnan_6015@y
1 Replies

2. Shell Programming and Scripting

Sorting By Column

I have almost got my unix program working that im working on as a personal project, my file tvs.txt has around 500 records so this would make it alot easier for me to find specific information. I have a file called tvs.txt, I'm using pico to edit the files and i want to be able to sort on the a... (6 Replies)
Discussion started by: john123
6 Replies

3. Shell Programming and Scripting

Sorting a particular column in PERL

I have a file abc.txt which contains data in th following format abc,23 hgfh,87 tweg,89 jdfjn,74 I want to sort on the basis of column (the second one). It should be numerical sort. output should be abc,23 jdfjn,74 hgfh,87 tweg,89 I know how to do it in unix. I need a PERL code (1 Reply)
Discussion started by: centurion_13
1 Replies

4. Shell Programming and Scripting

sorting on one column

Hello all, Is there a way to sort only one column while keeping everything else intact. Take for example this situation: (all columns are space separated) 11 AA asdf 1 -0.5 xx 11 AA axdf 1 -0.6 xx 11 AA csls 1 -0.7 xx 11 AA hjkj 1 -0.4 xx 11 AA uius 1 -0.8 xx 22 AA asdf 1 -0.4 xx 22 AA... (7 Replies)
Discussion started by: jaysean
7 Replies

5. Shell Programming and Scripting

[Solved] Sorting a column in a file based on a column in a second file

Hello, I have two files as the following: File1: F0100020 A G F0100030 A T F0100040 A G File2: F0100040 A G BTA-28763-no-rs 77.2692 F0100030 A T BTA-29334-no-rs 11.4989 F0100020 A G BTA-29515-no-rs 127.006 I want to sort the second file based on the... (6 Replies)
Discussion started by: Homa
6 Replies

6. Shell Programming and Scripting

[Solved] Sorting a column based on another column

hello, I have a file as follows: F0100010 A C F0100040 A G BTA-28763-no-rs 77.2692 F0100020 A G F0100030 A T BTA-29334-no-rs 11.4989 F0100030 A T F0100020 A G BTA-29515-no-rs 127.006 F0100040 A G F0100010 A C BTA-29644-no-rs 7.29827 F0100050 A... (9 Replies)
Discussion started by: Homa
9 Replies

7. UNIX for Dummies Questions & Answers

Searching a pattern and picking rows underneath them!

Hi, I have a requirement where i need to pick rows right below including the row where the search begins EX: USA CHINA INDIA 10 20 30 30 40 50 60 70 80 HON PAN SAN 50 60 70 80 90 100 So now...I need to get 2... (1 Reply)
Discussion started by: saggiboy10
1 Replies

8. UNIX for Dummies Questions & Answers

Independent column sorting

Dear All, I have a set of columns (usually unknown number) and I would like to sort each of them (descending values) but my columns are independent. Can you please help me file1 1,5,7 3,4,9 2,6,8 outcome should be 1,4,7 2,5,8 3,6,9 I have tried sort -n -k1,1 -k2,2 -k3,3 but this... (8 Replies)
Discussion started by: A-V
8 Replies

9. Shell Programming and Scripting

Sorting unique by column

I am trying to sort, do uniq by 1st column and report this 4 columns tab delimiter table , eg chr10:112174128 rs2255141 2E-10 Cholesterol, total chr10:112174128 rs2255141 7E-16 LDL chr10:17218291 rs10904908 3E-11 HDL Cholesterol chr10:17218291 rs970548 8E-9 TG... (4 Replies)
Discussion started by: fat
4 Replies

10. Shell Programming and Scripting

Sorting a specific column!

What im trying to do is sort the output by the number on the second column and than limit the result to only the first three lines. This is the code idlist="x23s52; f34233; 2343xs; 25x34; si342d" cntr=1 idcnt=$(print $nidlist |tr ';' '\n' |wc -l) numofgrps=0 while (($cntr <= $idcnt))... (3 Replies)
Discussion started by: ajetangay
3 Replies
sysinfo(2)							System Calls Manual							sysinfo(2)

NAME
sysinfo - manages system information strings SYNOPSIS
#include <sys/systeminfo.h> long sysinfo( int command, char *buf, long count ); PARAMETERS
Specifies the commands that manage the system information strings. They are described in the Available Commands section. Specifies the buffer used for the storage of system information. Specifies the size of the buffer pointed to by the buf parameter. DESCRIPTION
The sysinfo function retrieves and sets information relating to the operating system into a buffer pointed to by the buf parameter. This function is similar to the sysconf function which returns an integer instead of a string. Available Commands This section describes the commands that may be specified with the command parameter. The commands allow you to set certain attributes and they are listed in alphabetical order: Copies a string into the specified buffer that describes the instruction set of the current system's architecture. These names cannot conflict with predefined names in the C language compilation system. Copies a string into the specified buffer that represents the name of the present host machine. This is the same string that would be returned by the uname function in the nodename field. The name is typically the hostname or nodename that the machine is recognized by locally. The hostname is the name of the target machine as it is used in a network. Although the hostname may differ on various networks, the nodename that is presented to the appropriate network directory or name-to-address mapping service should produce a transport end point address. The name may not be fully qualified. Internet host names can be up to 256 bytes in length including the terminating null. Copies a string into the specified buffer that represents the name of the hardware manufacturer. This command is not supported in this implementation of the operating system. Copies a string into the specified buffer the ASCII representation of the hardware-specific serial number of the machine that exe- cuted the function call. This can be initiated in Read Only Memory through the software constants set when the machine is built. The string can contain non-numeric characters. This command is not supported in this implementation of the operating system. Copies a string into the specified buffer that represents the name of the machine. This is the same string that would be returned by the uname function in the machine field. Copies a string into the specified buffer that represents the name of the release. This is the same string that would be returned by the uname function in the release field. Copies the null-terminated contents of the specified buffer into the string that is maintained by the kernel. This value will be returned by successive calls to the sys- info function when used with the SI_HOSTNAME command. Superuser privileges are required to perform this action. Specifies that the string returned by the sysinfo function using the SI_SRPC_DOMAIN command is to be set to the value of the array pointed to by the buf parameter. This command is not supported in this implementation of the operating system. The command SI_SET_SYSNAME sets the system name. Copies the Secure Remote Procedure Call command name into the specified buffer. This command is not supported in this implementation of the operating system. Copies a string into the specified buffer the value that would be returned by the uname function in the sysname field. This is the name of the implementation of the operating system. RESTRICTIONS
Two commands, SI_SRPC_DOMAIN and SI_SET_SRPC_DOMAIN, are not currently supported. If either of these commands is specified, a value of -1 is returned and errno is set. RETURN VALUES
On success, the return value specifies the size in bytes required for the buffer to hold the value and terminating character of the string. If this value does not exceed the value specified in the count parameter, the string is copied. If this value exceeds the value specified by the count parameter, the string that is copied to the specified buffer is truncated to the count-1 bytes and a terminating character. If an error is encountered, a value of -1 is returned and errno is set to indicate the error. ERRORS
Specifies that the buf parameter does not point to a valid address, or that the data for a SET command is not allowed in this implementa- tion. Specifies that an invalid command was specified. See the RESTRICTIONS section. Specifies that the process does not have the appro- priate privileges for a SET command. SEE ALSO
Functions: getrlimit(2), setrlimit(2), sysconf(3), uname(2) sysinfo(2)
All times are GMT -4. The time now is 01:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy