automatic word wrapping


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting automatic word wrapping
# 1  
Old 01-29-2009
automatic word wrapping

Hallo,

I want to have this Output:
Code:
Name     Street   Phone    Mail     Favorite_thing_o
                                    f_what_ever_you_
                                    want
Jak      street1  0123     jak@test blue egs
                           .com
O'Neill  street2  4567     neil@tes red_horses_in_my
                           t.com    _ranch

I get the inputs from a file "inputs.txt" like this:
Code:
Name Street Phone Mail Favorite_thing_of_what_ever_you_want
Jak street1 0123 jak@test.com blue_egs
O'Neill street2 4567 neil@test.com red_horses_in_my_ranch

Is this possible with printf? How can I make this?

I need something like this:
Code:
printf "%8.s %8.s %8.s %8.s %16.s\n" `cat inputs.txt`

(the printf example above is nonsense, i know - but maybe there is any similar solution Smilie)

Last edited by wiseguy; 01-29-2009 at 04:51 AM..
# 2  
Old 01-29-2009
Too complicated for anything but perl (that I know of):
Code:
#!/bin/perl -w
format STDOUT_TOP =
Name     Street   Phone    Mail     Favorite thing
                                              of what ever you
                                               want
===============================================
.

@<<<<<< @<<<<<<< @<<<<<<< @<<<<<<<  ^<<<<<<<<<<<<<<<
@line
~~                        ^<<<<<<<  ^<<<<<<<<<<<<...
$line[-1]
.
while (<>) {
 @line=split(';');
 write;
}

Few perl coders today even realize this is what perl was initially designed for. Ah the good old days. Smilie

(Seriously, I didn't start using perl until probably version 4.009).

Last edited by otheus; 01-29-2009 at 05:14 AM.. Reason: email is also wrapped; added header
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX mail and wrapping

Greetings, I am by no means a Unix expert and hope that someone here can help me out. I am sending an email from within a Progress character program. This works fine. My issue is that I would like to send more than 80 characters and the email is wrapping at 80 chars. Is this an email... (9 Replies)
Discussion started by: Nosredna
9 Replies

2. Shell Programming and Scripting

SELECT and wrapping to next column

Hi all, Am trying to write a menu driven script using SELECT and if I have more than 4 options, it wraps to the next column. That is if I have 6 choices, items 5 and 6 are in the second column. Is there any settings that control this behavior or is it due to some stty settings? stty -a... (3 Replies)
Discussion started by: newbie_01
3 Replies

3. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

4. Shell Programming and Scripting

wrapping text not exceeding 80 characters

I have a file where the text might exceed 80 characters. I want to have the maximum text lengths to be 80, and cut text from a space. I written an awk script below but does not seem to work very well { gsub("\t"," ") $0 = line $0 while (length <= WIDTH) { line = $0 ... (3 Replies)
Discussion started by: kristinu
3 Replies

5. Shell Programming and Scripting

Line Wrapping using Sed

Hi, I want to wrap the lines if a line starts with number. I tried the following sed command, but I do not get the required output. It is replacing the first number. Can some one please help me on this? Command I used sed -e :a -e '$!N;s/\n//;ta' -e 'P;D' testfile I/P file:... (2 Replies)
Discussion started by: christineidanny
2 Replies

6. UNIX for Dummies Questions & Answers

Putty and wrapping on SunOS 5.9

I am very frustrated with this. I've added the following into my .profile and .bashrc: #this one makes sure that long commands strings line wrap to the next line && return #instead of wrapping onto the start of the same line. shopt -s checkwinsize However, it just never works for me.... (7 Replies)
Discussion started by: mrwatkin
7 Replies

7. Shell Programming and Scripting

Wrapping ksh script

Hi folks, We want to protect our ksh scripts from our customers.We don't want to let them the option to viewor modify the scripts. Is there a way ro wrap a ksh script? Thanks in advance, Nir (2 Replies)
Discussion started by: nir_s
2 Replies

8. Shell Programming and Scripting

Line wrapping problem when using awk

I am fairly new at this, I wrote a awk program to give me some summary information about a file. At the end of the program I want to print some variables but for some reason it keeps wrapping the last variable on a new line in the output file. Here is the print command print "99", file_id,... (1 Reply)
Discussion started by: placroix1
1 Replies

9. Shell Programming and Scripting

Wrapping a bash script for CGI

I hope its ok to start a new thread, I was going to use my existing one but thought a new one would better clarify things and provide better search for future reference. Well I have my bash program working now, all nice, user input validated, output formatted, everything is looking sexy. Now... (2 Replies)
Discussion started by: andyj
2 Replies
Login or Register to Ask a Question