help on formatting output (Table Form)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help on formatting output (Table Form)
# 1  
Old 01-18-2008
help on formatting output (Table Form)

Data in File

ABCSmilieEFGHI:123
ABCZYESmilieEFI:123
ABCFGDSmilieEF:123
ABCEERRRRRSmilieEFGHI:123

Expected Format

1 ABC DEFGHIFE 123
2 ABCZYE DEFI 123
3 ABCFGD DEF 123
4 ABCEERRRRR DEFGHI 123

However when i enter the following command:

awk 'BEGIN {FS=":"}{printf("%u %s\t%s\t%s\n", NR, $1, $2, $3)} END {print "End List"}' data.txt

Actual Output

1 ABC DEFGHIFE 123
2 ABCZYE DEFI 123
3 ABCFGD DEF 123
4 ABCEERRRRR DEFGHI 123

how can i set the width of each column?
# 2  
Old 01-18-2008
get rid of the tabs and use the field width within printf. check the man page for details.

ie:

Code:
printf "%20s\n" blah


Code:
     Field Width:
             An optional digit string specifying a field width; if the output
             string has fewer characters than the field width it will be blank-
             padded on the left (or right, if the left-adjustment indicator has
             been given) to make up the field width (note that a leading zero is
             a flag, but an embedded zero is part of a field width);



also - please use the code tags around your code/data. That way we do not see smiley
faces in the middle of your data.
# 3  
Old 01-18-2008
thank you very much.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

JSON structure to table form in awk, bash

Hello guys, I want to parse a JSON file in order to get the data in a table form. My JSON file is like this: { "document":{ "page": }, { "column": } ] }, { ... (6 Replies)
Discussion started by: Gescad
6 Replies

2. Shell Programming and Scripting

Table like formatting in Linux

Dear experts, I need bit help in formatting .. I have csv file file , i will read that file by passing one column value as input parameter and display header row and corresponding row for that parameter. I have shell script like this: #!/bin/bash #key_word_I_am_looking_for=$1 #awk... (16 Replies)
Discussion started by: onenessboy
16 Replies

3. Shell Programming and Scripting

Formatting in a table via shell

Hi I have the below output: 736f14c4-eda2-4531-9d40-9de4d6d1fb0f An account already exists for this email address. Please enter a different email address. c3716baf-9bf8-42da-8a44-a13fff68d20f An account already exists for this email address. Please enter a different email address. Is... (4 Replies)
Discussion started by: ankur328
4 Replies

4. Shell Programming and Scripting

I want query output to send on mail using table tag and output should be in table

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (21 Replies)
Discussion started by: ankit.mca.aaidu
21 Replies

5. Shell Programming and Scripting

Getting data in table form

Hi, I have a csv file from which i am fetching few columns as below: IFILE=/home/home1/Report1.csv OFILE=/home/home1/`date +"%m%d%y%H%M%S"`.dat if #Checks if file exists and readable then awk -F "," '(NR>4) {print $1,$6,$2,$3,$4,$5,$6}' ${IFILE} >> ${OFILE} fi cat $OFILE | mail... (7 Replies)
Discussion started by: Vivekit82
7 Replies

6. Shell Programming and Scripting

Dispaying output in tabular form

hi, I have a script which is dispaying the output as below: Column 3:value1 Column 4:value 4 column 8:value 8 column 9:value 9 column 13:value 13 Column 3:value10 Column 4:value 40 column 8:value 80 column 9:value 90 column 13:value 103 However,I need the output in tabular... (5 Replies)
Discussion started by: Vivekit82
5 Replies

7. Shell Programming and Scripting

Displaying log file pattern output in tabular form output

Hi All, I have result log file which looks like this (below): from the content need to consolidate the result and put it in tabular form 1). Intercomponents Checking Passed: All Server are passed. ====================================================================== 2). OS version Checking... (9 Replies)
Discussion started by: Optimus81
9 Replies

8. Shell Programming and Scripting

Converting form field to table format

May data Name = Andi Address = none Phone = 82728 Name = Peter Address = none Phone = 98799 The expected output Name,Address,Phone Andi,none,82728 Peter,none,98799 what i have done (6 Replies)
Discussion started by: before4
6 Replies

9. Shell Programming and Scripting

quired output in form of

hi frnds, i have a file: where 1st field is: eventType,eventTime,loggingTime, probableCause,lsname,slCode and is 2nd field hav its values and everytime its starting with communicationsAlarm on the behalf of communicationsAlarm eventType communicationsAlarm, ... (3 Replies)
Discussion started by: dodasajan
3 Replies
Login or Register to Ask a Question