How to format a txt file using typeset?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to format a txt file using typeset?
# 1  
Old 12-04-2003
How to format a txt file using typeset?

Hi all,

i have a file toto.txt :


blabla;toumtoudoum;blablabla
toumtoudoumtoudoum;blabla;popopopo
blablabla;etcetcetc;blabla

etc....



As you can see, it is a simple file containig 3 fields separated by a ";".

What i want to do is to display this file with a nice formating (by columns) :


blabla.............................toumtoudoum.......................blablabla
toumtoudoumtoudoum........blabla................................popopopo
blablabla.........................etcetcetc..............................blabla

etc....


(without using "....." Smilie )

After a few searchs, i found that using "typeset" would be useful...but i don't know really how


any ideas?

thx

Cheers,

Howard
# 2  
Old 12-04-2003
I used the following text for test.

cat test.file
a;a;a
b;b;b
c;c;c

awk -F";" '{printf "%s%10s%10s", $1,$2,$3}' test.file

a a a
b b b
c c c

try it.
# 3  
Old 12-04-2003
Yeaaaaaah,

your answer was nearly the perfect solution. I rearranged it to obtain the following command line :

$ cat toto.txt | awk -F ";" '{printf "%20s %20s %20s\n", $1,$2,$3}'



ANd it works perfectly !


Thx !!! Smilie
# 4  
Old 12-04-2003
just being inquisitive,

if you need the entire file anyway, then why cat it and then pipe it, instead directly pass it as last arg to awk, as shown by tikual

Is there some performance issue you foresee, or is it just your style

thanks!!
# 5  
Old 12-05-2003
I guess it' my (bad?) style....

I try to do my best using the few unix commands i know.

Smilie

And i have to admit that when i write something that works, i don't make the efforts to optimize my code....Smilie


Thx for your remark! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Format txt file in UNIX

Hello All, I have File_all.txt which have content as below Volume in drive E is Data Volume Serial Number is 586D-6932 Directory of E:\mydi2\siudfor\TFG058 03/27/2014 09:59 PM 5,569 FX\FX01 my4_pg4_MON_20140327_C.zip 1 File(s) 5,569 bytes ... (5 Replies)
Discussion started by: kumar30213
5 Replies

2. Shell Programming and Scripting

Need help to format one txt file to required format

Hello Everyone, I have one source file which is genarated by SAP in different format(Which I've never seen). I need to convert that file to required format and I need to read this target file from Datastage to use this in my Jobs. So I do not have any other options except to use Unix script to... (4 Replies)
Discussion started by: Prathyu
4 Replies

3. Shell Programming and Scripting

Need to append the date | abcddate.txt to the first line of my txt file

I want to add/append the info in the following format to my.txt file. 20130702|abcd20130702.txt FN|SN|DOB I tried the below script but it throws me some exceptions. <#!/bin/sh dt = date '+%y%m%d'members; echo $dt+|+members+$dt; /usr/bin/awk -f BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Discussion started by: harik1982
6 Replies

4. UNIX and Linux Applications

Ssmtp -t < /path/to/the/message.txt (How to format message.txt for html email)

ssmtp has been running well under Kubuntu 12.04.1 for plain text messages. I would like to send html messages with ssmtp -t < /path/to/the/message.txt, but I cannot seem to get the message.txt file properly formatted. I have tried various charsets, Content-Transfer-Encoding, rearranging the... (0 Replies)
Discussion started by: Ronald B
0 Replies

5. Shell Programming and Scripting

awk append fileA.txt to growing file B.txt

This is appending a column. My question is fairly simple. I have a program generating data in a form like so: 1 20 2 22 3 23 4 12 5 43 For ever iteration I'm generating this data. I have the basic idea with cut -f 2 fileA.txt | paste -d >> FileB.txt ???? I want FileB.txt to grow, and... (4 Replies)
Discussion started by: theawknewbie
4 Replies

6. Shell Programming and Scripting

Format txt file as html table

I have a short time to solve a problem, so I need some help. I've searched the forum, but I couldn't find a solution to my problem. I made a script to filter some text and now I have a new requirement to make it available as html table. Problem is that I more than one files with different set... (2 Replies)
Discussion started by: tetreb
2 Replies

7. Shell Programming and Scripting

Format txt file to CSV

Hi All, I have a file with content FLIGHT PLANS PRODUCED ON 26.08.2008(SORTED BY FPLAN NUMBER) RUN DATED 27/08/08 PAGE 1 -------------------------------------------------------------- FPLAN FPLAN PRE BTCH BATCH POST BTCH BATCH BATCH ... (1 Reply)
Discussion started by: digitalrg
1 Replies

8. UNIX for Dummies Questions & Answers

Save Excel file as .txt in UNIX format

I have some files created in Excel that have to be saved as .txt files in order to load them into our accounting system. I can save the files as .txt files through Excel, but I then have to open them in TextPad and do a save as to change the Format from PC to UNIX. Is there a way to skip this step... (2 Replies)
Discussion started by: jroyalty
2 Replies

9. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

HI guys, I have created a script to read 1 column in a csv file and then place it in text file. However, when i checked out the text file, it is not in a column format... Example: CSV file contains name,age aa,11 bb,22 cc,33 After using awk to get first column TXT file... (1 Reply)
Discussion started by: mdap
1 Replies

10. UNIX for Dummies Questions & Answers

Binary txt file received when i use uuencode to send txt file as attachment

Hi, I have already read a lot of posts on sending attachments in unix...but none of them were of help for my problem...so here goes.. i wanna attach a text file and send to a mail id..used the following code : uuencode "$File1" "$File1" ;|mail -s "$Mail_sub" abc@abc.com it works... (2 Replies)
Discussion started by: ash22
2 Replies
Login or Register to Ask a Question