Sponsored Content
Top Forums Shell Programming and Scripting [bash scripting] Generating a table with aligned fields Post 302305876 by vidyadhar85 on Friday 10th of April 2009 03:00:13 AM
Old 04-10-2009
this should work fast..
Code:
no=`awk -F":" -v l=\`awk 'END{print NR}' filename\` '
{A[NR]=length($1)" "length($2)" "length($3)" "length($4)" "length($5)" "length($6)" "length($7)" "length($8)" "length($9)}
END{for(i=0;i<l;++i)
{split(A[i],B," ");
{if(B[1]>max1){max1=B[1]}}
{if(B[2]>max2){max2=B[2]}}
{if(B[3]>max3){max3=B[3]}}
{if(B[4]>max4){max4=B[4]}}
{if(B[5]>max5){max5=B[5]}}
{if(B[6]>max6){max6=B[6]}}
{if(B[7]>max7){max7=B[7]}}
{if(B[8]>max8){max8=B[8]}}
{if(B[9]>max9){max9=B[9]}}
}{print max1" "max2" "max3" "max4" "max5" "max6" "max7" "max8" "max9}}' filename`
awk -F":" -v var="$no" '{split(var,A," ")}{printf "%-"A[1]"s %-"A[2]"s %-"A[3]"s %-"A[4]"s %-"A[5]"s %-"A[6]"s %-"A[7]"s %-"A[8]"s %-"A[9]"s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9}' filename

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash Scripts - File generating

Forgive the daft requests - I'm still a learner :D I need a script so that I can test another script (I'm confused already) The script I am looking for should generate a new file in the same directory (called newfile1 or what ever) and also generate text within the new file (Hello world? What... (1 Reply)
Discussion started by: JayC89
1 Replies

2. Shell Programming and Scripting

Create a table using shell scripting

Hi Can we create a rectangular table as i have attached in the query . This is primarily for populating the created table with data gathered . Hope I made myself clear ... Pls suggest Thanks (1 Reply)
Discussion started by: ultimatix
1 Replies

3. Shell Programming and Scripting

generating report in Excel(Open office) using shell scripting

Hello All, I need to execute around 15 queries after which all data should come in Excel format. Executing 15 queries is not a problem. Problem is how to present/put data in excel. kindly suggest me how to start, what to study or what should i do. thanks, (1 Reply)
Discussion started by: shubham8787
1 Replies

4. Shell Programming and Scripting

Novice in shell scripting - generating report

Hi I recently joined a project where I have been asked to generate a report using shell script accessing UNIX box. I have no idea on how to do it as I am a beginner and learning shell scripts. Suppose I have a XML: <XYZRequest> <effectiveDate>someDate</effectiveDate>... (2 Replies)
Discussion started by: vat1kor
2 Replies

5. Shell Programming and Scripting

Converting date/time and generating offsets in bash script

Hi all, I need a script to do some date/time conversion. It should take as an input a particular time. It should then generates a series of offsets, in both hour:minute form and number of milliseconds elapsed. For 03:00, for example, it should give back 04:02:07 (3727000ms*) 05:04:14... (2 Replies)
Discussion started by: emdan
2 Replies

6. Shell Programming and Scripting

Table Scripting

Okay. I've been charged with an assignment to create tables. I "Made" a manufacturing company called "Suit and Tie". I need subdirectories for the company, using three departments: Human resources, Manufacturing, and Sales. 1) mkdir Suit_and_Tie 2) cd Suit_and_Tie 3) mkdir Human... (3 Replies)
Discussion started by: Catori
3 Replies

7. Homework & Coursework Questions

Table Scripting

1. The problem statement, all variables and given/known data: I have to make a manufacturing company. I need subdirectories for the company using three departments: Human Resources, Manufacturing, and Sales. I also need three scripts in order to create tables for each sub directory. Each script... (11 Replies)
Discussion started by: Catori
11 Replies

8. Programming

Celisus & fahrenheit table converter with fields + increments

no longer needed, please delete thread. (0 Replies)
Discussion started by: xtina
0 Replies

9. UNIX for Advanced & Expert Users

How can i populate the record in to table using shell scripting?

LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( echo "From: $pzFrom\nTo: $pzTo\nSubject: $pzTitle${pzReplyTo:+\nReply-To: $pzReplyTo}" ] && echo... (1 Reply)
Discussion started by: ankit.mca.aaidu
1 Replies

10. Forum Support Area for Unregistered Users & Account Problems

Creation of Oracle table through shell scripting

Hi, I am trying to create a table through shell scripting . I used a command sqlplus -s to connect to sqlplus and user as sysdba. but there is a problem in it. can anyone please solve this . #!/bin/bash $(`sqlplus -s / as sysdba <<eof create table sample (id,int); insert into sample... (1 Reply)
Discussion started by: Unregistered
1 Replies
get_midi_length(3alleg4)					  Allegro manual					  get_midi_length(3alleg4)

NAME
get_midi_length - Determines the total playing time of a midi, in seconds. Allegro game programming library. SYNOPSIS
#include <allegro.h> int get_midi_length(MIDI *midi); DESCRIPTION
This function will simulate playing the given MIDI, from start to end, to determine how long it takes to play. After calling this function, midi_pos will contain the negative number of beats, and midi_time the length of the midi, in seconds. Note that any currently playing midi is stopped when you call this function. Usually you would call it before play_midi, to get the length of the midi to be played, like in this example: length = get_midi_length(my_midi); play_midi(my_midi); do { pos = midi_time; textprintf_ex(screen, font, 0, 0, c, -1, "%d:%02d / %d:%02d ", pos / 60, pos % 60, length / 60, length % 60); rest(100); } while(pos <= length); RETURN VALUE
Returns the value of midi_time, the length of the midi. SEE ALSO
load_midi(3alleg4), midi_time(3alleg4), midi_pos(3alleg4), exmidi(3alleg4) Allegro version 4.4.2 get_midi_length(3alleg4)
All times are GMT -4. The time now is 01:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy