Sponsored Content
Top Forums Shell Programming and Scripting awk to convert table-by-row to matrix table Post 302881911 by disedorgue on Thursday 2nd of January 2014 06:36:25 PM
Old 01-02-2014
Try this:
Code:
$ awk -F'[ :,]' '{PROCINFO["sorted_in"]="@ind_str_asc"; A[$1]=1;for (i=3;i<=NF;i++) {C[$i]=$i;B[$1,$i]=$2}}END{printf "SITE\t";for ( jj in C ) printf jj" ";print "" ; for ( ii in A ) {printf ii"\t";for ( jj in C ) {if (B[ii,jj]) {printf B[ii,jj]" "} else {printf "- "}}; print ""}}' infile

Regards.
This User Gave Thanks to disedorgue For This Post:
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Is it possible to draw table/matrix using shell script?

Hi all, I need to create a matrix of variable rows and columns. Right now i have 3 rows and two columns and following values. Output something like TypeA TypeB TestCase1 Pass Fail TestCase2 Pass ... (2 Replies)
Discussion started by: jakSun8
2 Replies

2. UNIX for Dummies Questions & Answers

convert matrix to row and columns

Dear Unix Gurus, I have a sample data set that looks like this y1 y2 y3 y4 y5 x1 0.3 0.5 2.3 3.1 5.1 x2 1.2 4.1 3.5 1.7 1.2 x3 3.1 2.1 1.0 4.1 2.1 x4 5.0 4.0 6.0 7.0 1.1 I want to open it up so that I get x1 y1 0.3 x2 y1 1.2 x3 y1 3.1 x4 y1 5.0 x1 y2 0.5 x2 y2... (3 Replies)
Discussion started by: tintin72
3 Replies

3. UNIX for Dummies Questions & Answers

Shell Script: Traverse Database Table Row by Row

Hello Everyone, My issue is that I want to traverse a database table row by row and do some action on the value retrieved in each row. I have gone through a lot of shell script questions/posts. I could find row by row traversal of a file but not a database table. Please help. Thanks &... (5 Replies)
Discussion started by: ahsan.asghar
5 Replies

4. Shell Programming and Scripting

Table to Matrix

Hi, I have a table in the format: 1 0 -1 1 0 2 0 1 -1 0 0 0 3 0 1 1 0 0 0 0 0 0 etc. I am trying to input this to a program, however it is complaining about the fact that it is not in matrix format. How do I add 0's to end of the rows to make them even? Thanks in advance! (2 Replies)
Discussion started by: Rhavin
2 Replies

5. Shell Programming and Scripting

Read in Table as a matrix

Dear forum users, i'm trying to read a table with 40x122 data in a array. Following this, i'd plot each rows again the header of the file in gnuplot. i was thinking for something like that #!/bin/bash # reads from the $ips file and assigns to $MYARRAY #IFS =";" split the line after the... (6 Replies)
Discussion started by: servuskelb
6 Replies

6. Shell Programming and Scripting

How to sort matrix table in UNIX?

Hello All, i have a file sort.txt with below entries. 1 12 10 16 6 4 20 8 15 i need to sort these entries and the out put should come in a single line. 1 4 6 8 10 12 15 16 20 Can you please help me sort this out? (2 Replies)
Discussion started by: sureshk_85
2 Replies

7. Shell Programming and Scripting

In php, Moving a new row to another table and deleting old row

Hi, I already succeed moving a new row to another table if the field from new row doesn't have the first word that I categorized (like: IRC blablabla, PTM blablabla, ADM blablabla, BS blablabla). But it can't delete the old row. Please help me with the script. my php script: INSERT INTO... (2 Replies)
Discussion started by: jazzyzha
2 Replies

8. Shell Programming and Scripting

Convert rows into columns and create table with awk

Hello I've four fields . They are First Name, Last Name, Age, Country. So when I run a Unix command, I get below output with these fields comes every time in different order as you can see. Some times first name is the first row and other time last name is first row in the output and etc etc..... (9 Replies)
Discussion started by: rprpr
9 Replies
PROCINFO-NG(8)							Linux System Manual						    PROCINFO-NG(8)

NAME
procinfo - display system statistics gathered from /proc SYNOPSIS
procinfo [ -fdDSbrhv ] [ -nN ] DESCRIPTION
procinfo gathers some system data from the /proc directory and prints it nicely formatted on the standard output device. The meanings of the fields are as follows: Memory: See the man page for free(1) Bootup: The time the system was booted. Load average: The average number of jobs running, followed by the number of runnable processes and the total number of processes, followed by the PID of the last process run. The pid of the last running process will probably always be procinfo's PID. user: The amount of time spent running jobs in user space. nice: The amount of time spent running niced jobs in user space. system: The amount of time spent running in kernel space. Note: the time spent servicing interrupts is not counted by the kernel (and noth- ing that procinfo can do about it). idle: The amount of time spent doing nothing. uptime: The time that the system has been up. The above four should more or less add up to this one. page in: The number of disk blocks paged into core from disk. 1 block is equal to 1 kiB. page out: The number of disk blocks paged out of core to disk. This includes regular disk-writes. swap in: The number of memory pages paged in from swap. swap out: The number of memory pages paged out to swap. context: The number of context switches, either since bootup or per interval. Disk stats(hda, hdb, sda, sdb): The number of reads and writes made to disks, whether CD-ROM, hard-drive, or USB. Shows all disks if they either are an hdX or sdX, or if they have a non-zero read/write count. Interrupts: Number of interrupts serviced since boot, or per interval, listed per IRQ. OPTIONS
-nN Pause N second between updates. This option implies -f. It may contain a decimal point. The default is 5 seconds. When run by root with a pause of 0 seconds, the program will run at the highest possible priority level. -d For memory, CPU times, paging, swapping, disk, context and interrupt stats, display values per second rather than totals. This option implies -f. -D Same as -d, except that memory stats are displayed as totals. -S When running with -d or -D, always show values per second, even when running with -n N with N greater than one second. -b Display numbers of bytes rather than number of I/O requests. -r This option adds an extra line to the memory info showing 'real' free memory, just as free(1) does. The numbers produced assume that Buffers and Cache are disposable. -H Displays memory stats in 'Human' (base 1024) numbers (KiB, MiB, GiB), instead of implied KBytes. -h Print a brief help message. -v Print version info. INTERACTIVE COMMANDS
When running procinfo fullscreen, you can change its behaviour by pressing d, D, S, r and b, which toggle the flags that correspond to their same-named commandline-options. In addition you can press q which quits the program. FILES
/proc The proc file system. BUGS
All of these statistics are taken verbatim from the kernel, without any scaling. Any case where the kernel specifies that a particular field means something different from how it is documented in this man-page, the kernel always wins. Some features of the original procinfo were elided, as they were considered non-useful, especially as many of them don't change anymore, and have better utilities for listing/displaying them. SEE ALSO
free(1), uptime(1), w(1), init(8), proc(5). AUTHOR
Adam Schrotenboer <adam@tabris.net> v2.0 2007-05-05 PROCINFO-NG(8)
All times are GMT -4. The time now is 03:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy