Sponsored Content
Full Discussion: Creating a table
Top Forums Shell Programming and Scripting Creating a table Post 302431301 by kristinu on Monday 21st of June 2010 04:53:12 PM
Old 06-21-2010
Creating a table

I have a file like below

Code:
Iter 1: Best Model = 10.0 12.0 13.0 17.0 23.3 78.7
Iter 2: Best Model = 10.0 20.0 30.0 40.0 50.0 60.0
Iter 3: Best Model = 27.3 46.3 84.5 23.0 34.5 35.4

etc

I want to use a scipts using csh or awk to select the iteration number and show the numbers in a table

For example user inputs iter=2 Nx=3 Ny=2
where Nx times Ny is the total number of values in the line at iter 2

The total number of values in each line is always the same.

We find the values associated with iter=2 and create the table

Code:
10.0 30.0 50.0
20.0 40.0 60.0



---------- Post updated at 03:53 PM ---------- Previous update was at 10:39 AM ----------

I have tried to write an awk script to do this. However cant't get $(i+j) to work.

Code:
{
    NX = 16
    NY = 12
    for (i = 1; i <= NX; ++i ) {
      var = ""
      j = 0
      for (j = 1; j <= NY; ++i ) {
        var = var ${i+j}
        j = j+ NX
      }
    print "var\n"
    }
  }

I have created a small text file with

1 2 3 4 5 6 7 8 9 10 11 12

and want to get a table which I call 4x3

1 4 7 10
2 5 8 11
3 6 9 12

using the following

Code:
{
    NX = 4
    NY = 3
    for (i = 1; i <= NY; ++i ) {
      var = ""
      j = 0
      for (j = 0; j <= NX; ++j ) {
        k = i + j
        var = var" "$k
        j = j + NX
      }
    print var
    }
  }

However this only gives me

1
2
3

Last edited by kristinu; 06-21-2010 at 06:25 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Creating a hash table using shell script

Hi, For one of my programs, I need to have a hashtable as in Perl. Unfortunately shell doesnt provide any variable like hash. Is there anyway/trick, I could implement a hash in shell (using shell scripts/sed/awk). JP (2 Replies)
Discussion started by: jyotipg
2 Replies

2. Programming

Creating a Hash Table

Dear Friends, I want to create a hash table using the standard Glib header (if possible) so that I can store a structure and keep the hash key(search key) based on a string. Any example code would be great since I am not able to get the main idea. best regards Skull (4 Replies)
Discussion started by: callmetheskull
4 Replies

3. UNIX for Dummies Questions & Answers

Creating a table (graphic not database)

Hi, I want to create a table on our unix box that allows the user to tab through it and select certain option by putting an asterix or similair into it. e.g. -------------- |Start App | | |Stop App |*| etc... Can this be done using a script (never seen any graphics options in ksh, but... (2 Replies)
Discussion started by: dlam
2 Replies

4. Shell Programming and Scripting

Creating table in Unix

Hi All, In a given directory, I need to list the files present in it in the below given format as a table. File name Permission Number of Bytes File Type Telecom1 --w-r-x 1230 Directory Telecom2 ---x---x---x 450 Device file Telecom3 ... (7 Replies)
Discussion started by: mr_manii
7 Replies

5. Programming

Creating a table like format with rows and columns

I have few files which have two columns in each. like e2 1 1 2694 2 4 2485 3 2 2098 5 1 2079 6 5 2022 9 4 1734 11 5 1585 13 2 1461 18 1 1092 21 2 1019 24 1 915 25 3 907 27 1 891 28 3 890 34 1 748 39 1 700 (1 Reply)
Discussion started by: kamuju
1 Replies

6. Web Development

MYSQL: Creating Dynamic Table Names 5.1

Hey everyone. Thanks for looking at this. I'm trying to create a table with the dynamic name of TableName + today's date. My variables are all happily created but the system chokes when I try to create the new table name example: Set @BFBW = CONCAT("BFBW", CURDATE()); Select @BFBW; ... (2 Replies)
Discussion started by: Astrocloud
2 Replies

7. UNIX for Dummies Questions & Answers

Creating a condensed table from a pre-existing table in putty

Hello, I'm working with putty on Windows 7 professional and I'd like to know if there's a way to gather specific lines from a pre-existing table and make a new table with that information. More specifically, I'd like the program to look at a specific column, say column N, and see if any of the... (5 Replies)
Discussion started by: Deedee393
5 Replies

8. UNIX for Advanced & Expert Users

Insert Command Creating Table Locking Problem

Hi, i have a java based tool which does insert operation in a TABLE, and in parallel the same table is used by my C++ code which does select Query. the Table will be always busy, but sometimes the table is getting locked when i try to make an insert, am bit confused whether the lock is... (9 Replies)
Discussion started by: senkerth
9 Replies

9. Shell Programming and Scripting

Creating html table from data in file

Hi. I need to create html table from file which contains data. No awk please :) In example, ->cat file num1 num2 num3 23 3 5 2 3 4 (between numbers and words single TAB). after running mycode i need to get (heading is the first line): <table>... (2 Replies)
Discussion started by: Manu1234567
2 Replies
Config::Model::Exception(3pm)				User Contributed Perl Documentation			     Config::Model::Exception(3pm)

NAME
Config::Model::Exception - Exception mechanism for configuration model VERSION
version 2.021 SYNOPSIS
# internal DESCRIPTION
You must read Exception::Class before reading on. This module creates all the exception class used by Config::Model. All exception class name begins with "Config::Model::Exception::" The exception classes are: "Any" Base class. It accepts an "object" argument. The user must pass the reference of the object where the exception occurred. The object name will be used to generate the error message. TODO: list all exception classes and hierarchy. How to get trace By default, most of the exceptions will not print out the stack trace. For debug purpose, you can force a stack trace. For instance, if you want a stack trace for an "unknown element" error, you must add this line in your script: Config::Model::Exception::UnknownElement->Trace(1) ; If you're not sure which class to trace, add this line in your script: Config::Model::Exception::Any->Trace(1) ; AUTHOR
Dominique Dumont, (ddumont at cpan dot org) SEE ALSO
Config::Model, Config::Model::Instance, Config::Model::Node, Config::Model::Value Exception::Class perl v5.14.2 2012-11-09 Config::Model::Exception(3pm)
All times are GMT -4. The time now is 05:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy