Sponsored Content
Full Discussion: Align Text from a file.
Top Forums UNIX for Dummies Questions & Answers Align Text from a file. Post 302082182 by jim mcnamara on Monday 31st of July 2006 02:45:38 PM
Old 07-31-2006
Code:
#!/bin/ksh

tr -s ' ' ',' < test  > tmpfile
awk -F, ' \
     {
	   printf("%8s %12s %4s ", $1, $2, $3)
           for(i=4;i<=NF;i++)
           {
           	 printf("%10.3f ",$i)
           }
           printf("\n")
     } ' tmpfile

output:
Code:
05/14/06 13:46:56.575 TEST      5.000    123.000   1234.000    123.000  12345.000     12.000     12.200      2.100      4.500      5.230
05/14/06 13:49:58.009 TEST      6.000    456.000    456.700     45.000      4.560    453.000     34.000     54.300      3.200      6.456

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Align Text within <p> Tags in a HTML file.

Hi All !!! I have an HTML file whose contents are as below: <html> <body> <title>This is a test file</title> <p>PLEASE ALIGN ME IN ONE LINE. TEXT....</p> <h2>This is a Test file</h2> <p>PLEASE ALIGN ME IN ONE LINE. TEXT....</p> </body> </html> (2 Replies)
Discussion started by: parshant_bvcoe
2 Replies

2. Shell Programming and Scripting

Align the words

HI , I am new to shell scripting i m getting the below format like this Name FirstName Lastname ------ --------- ---------- Name1 Balaji NandaKishore Name123 Vijaya krsihna ... (5 Replies)
Discussion started by: Lucky123
5 Replies

3. Shell Programming and Scripting

Get the ipaddress and align based on the input file

Hi All, I have a file contains below contents, "interfacename/subnet: public (or) interfacename/subnet:cluster_interconnect" "en2"/10.185.81.0:cluster_interconnect,"en5"/10.185.81.0:cluster_interconnect,"en6"/169.181.146.0:public... (6 Replies)
Discussion started by: kamauv234
6 Replies

4. Shell Programming and Scripting

Left Align of Text File

Input: hiddenhausen 99.60 y 1.05 2.50 -550 -110 1:25:200 herbstein 99.021 n 1.05 2.50 -550 -110 1:25:200 bangalore 98.82 y 1.05 2.50 -550 -110 1:25:200 golm 98.8 y 1.05 2.50 -550 -110 1:25:200 para 98.82 n 1.05 2.50 -550 -110 1:25:200 bogen 98.61 n 1.05 2.50 -550 -110 1:25:200 saintandre... (5 Replies)
Discussion started by: asavaliya
5 Replies

5. Shell Programming and Scripting

Align data of the paragraph

Hi, I need your help to align data from paragraph. It's to : - delete the lign contain NDS - align data between paragraph start to "ND=" from second "ND=" example of file: @ ABOIL; @ CEN=1/15-05-23/09 H 06 MN 18/LISTAGE CARACTERISTIQUES D'ABONNES TRAITEMENT TGLAIL ACC... (1 Reply)
Discussion started by: vremen3
1 Replies

6. Shell Programming and Scripting

Align columns

Hi, I have a question on how to align columns in shellscipt. SAMPLE 2015-07-15 09:01:00.0 |TCSERVER01 |10965 2015-07-15 09:02:00.0 |TCSERVER01 |4752 2015-07-15 09:03:00.0 |TCSERVER01 |4805 2015-07-15 09:04:00.0 |TCSERVER01 |3690 2015-07-15 09:01:00.0 |TCSERVER02 |8703 2015-07-15... (1 Reply)
Discussion started by: reignangel2003
1 Replies

7. Shell Programming and Scripting

Align input fields on one under each other

Hello again, I'm having a issue with a contact form. I want the input fields to be aligned on same row and I really dont know how to do it. I attached a image for you to understand what i am trying to do. <BR> <label for="name" class="required"> Name&nbsp;<strong... (1 Reply)
Discussion started by: galford
1 Replies

8. Shell Programming and Scripting

Align columns

I have a text file that I filtered using awk. I only exctracted two columns. I want those two columns to be aligned. Most of the answers I found was to use `column -t` command. I tried that but I am getting a `bash: column: command not found`. Is there another way to align columns... (1 Reply)
Discussion started by: erin00
1 Replies

9. UNIX for Beginners Questions & Answers

How to align/sort the column pairs of an csv file, based on keyword word specified in another file?

I have a csv file as shown below, xop_thy 80 avr_njk 50 str_nyu 60 avr_irt 70 str_nhj 60 avr_ngt 50 str_tgt 80 xop_nmg 50 xop_nth 40 cyv_gty 40 cop_thl 40 vir_tyk 80 vir_plo 20 vir_thk 40 ijk_yuc 70 cop_thy 70 ijk_yuc 80 irt_hgt 80 I need to align/sort the csv file based... (7 Replies)
Discussion started by: dineshkumarsrk
7 Replies

10. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
Text::Align(3)						User Contributed Perl Documentation					    Text::Align(3)

NAME
GD::Text::Align - Draw aligned strings SYNOPSIS
use GD; use GD::Text::Align; my $gd = GD::Image->new(800,600); # allocate colours, do other things. my $align = GD::Text::Align->new($gd valign => 'top', halign => 'right', ); $align->set_font('arial', 12); $align->set_text('some string'); @bb = $align->bounding_box(200, 400, PI/3); # you can do things based on the bounding box here $align->draw(200, 400, PI/3); DESCRIPTION
GD::Text::Align provides an object that draws a string aligned to a coordinate at an angle. For builtin fonts only two angles are valid: 0 and PI/2. All other angles will be converted to one of these two. METHODS
This class inherits everything from GD::Text. I will only discuss the methods and attributes here that are not discussed there, or that have a different interface or behaviour. Methods directly inherited include "set_text" and "set_font". GD::Text::Align->new($gd_object, attrib => value, ...) Create a new object. The first argument to new has to be a valid GD::Image object. The other arguments will be passed on to the set method. $align->set(attrib => value, ...) Set an attribute. Valid attributes are the ones discussed in GD::Text and: valign, halign Vertical and horizontal alignment of the string. See also set_valign and set_halign. colour, color Synonyms. The colour to use to draw the string. This should be the index of the colour in the GD::Image object's palette. The default value is the last colour in the GD object's palette at the time of the creation of $align. $align->get(attribute) Get the value of an attribute. Valid attributes are all the attributes mentioned in GD::Text, the attributes mentioned under the "set" method and x, y and angle The x and y coordinate and the angle to be used. You can only do this after a call to the draw or bounding_box methods. Note that these coordinates are not necessarily the same ones that were passed in. Instead, they are the coordinates from where the GD methods will start drawing. I doubt that this is very useful to anyone. Note that while you can set the colour with both 'color' and 'colour', you can only get it as 'colour'. Sorry, but such is life in Australia. $align->set_valign(value) Set the vertical alignment of the string to one of 'top', 'center', 'base' or 'bottom'. For builtin fonts the last two are the same. The value 'base' denotes the baseline of a TrueType font. Returns true on success, false on failure. $align->set_halign(value) Set the horizontal alignment of the string to one of 'left', 'center', or 'right'. Returns true on success, false on failure. $align->set_align(valign, halign) Set the vertical and horizontal alignment. Just here for convenience. See also "set_valign" and "set_halign". Returns true on success, false on failure. $align->draw(x, y, angle) Draw the string at coordinates x, y at an angle angle in radians. The x and y coordinate become the pivot around which the string rotates. Note that for the builtin GD fonts the only two valid angles are 0 and PI/2. Returns the bounding box of the drawn string (see "bounding_box()"). $align->bounding_box(x, y, angle) Return the bounding box of the string to draw. This returns an eight-element list (exactly like the GD::Image->stringTTF method): (x1,y1) lower left corner (x2,y2) lower right corner (x3,y3) upper right corner (x4,y4) upper left corner Note that upper, lower, left and right are relative to the string, not to the canvas. The bounding box can be used to make decisions about whether to move the string or change the font size prior to actually drawing the string. NOTES
As with all Modules for Perl: Please stick to using the interface. If you try to fiddle too much with knowledge of the internals of this module, you may get burned. I may change them at any time. You can only use TrueType fonts with version of GD > 1.20, and then only if compiled with support for this. If you attempt to do it anyway, you will get errors. In the following, terms like 'top', 'upper', 'left' and the like are all relative to the string to be drawn, not to the canvas. BUGS
Any bugs inherited from GD::Text. COPYRIGHT
copyright 1999 Martien Verbruggen (mgjv@comdyn.com.au) SEE ALSO
GD, GD::Text, GD::Text::Wrap perl v5.12.1 2003-02-24 Text::Align(3)
All times are GMT -4. The time now is 09:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy