The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cut - columns with formatted Output dhanamurthy Shell Programming and Scripting 9 05-19-2008 10:20 AM
Formatted Output dhanamurthy Shell Programming and Scripting 6 05-13-2008 02:30 AM
formatted output with commas joeyg Shell Programming and Scripting 4 03-04-2008 03:54 PM
Formatted output in KSH psynaps3 Shell Programming and Scripting 1 07-05-2006 08:03 AM
Validating a formatted message BrianOsburn Shell Programming and Scripting 10 08-12-2003 05:13 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-11-2008
dhanamurthy dhanamurthy is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 105
Formatted output - awk

Hi

I have the following records in a file

SABN YOURTUBE 000514 7256
SACN XYOUDSDF 000514 7356
SADN KEHLHRSER 000514 7656
SAEN YOURTUBE 000514 7156
SAFN YOURTUBE 000514 7056

I need to put this in the format like this

printf '%s %-50s %6s %-6s\n'
I am not going to read individual lines and do a printf as the processing time taken is in hours which is not expected.

I would like to cut the entire column 1,2,3,4 and output in the printf format given above.
Any examples would be appreciated.

Regards
Dhana
  #2 (permalink)  
Old 05-11-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Quote:
Originally Posted by dhanamurthy View Post
I am not going to read individual lines and do a printf as the processing time taken is in hours which is not expected.
Do you mean that the processing time is very slow in awk, or reading individual lines by some other method? Can you show us your code?

awk has printf built-in, so I don't understand what exactly you need help with.
  #3 (permalink)  
Old 05-11-2008
dhanamurthy dhanamurthy is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 105
Formatted Output - Awk

Hi

I have been reading individual lines of the file using sed and
cutting the columns that i need and using

printf '%s %-50s %6s %-6s %s\n'

I was able to achieve my things. But i am reading a 1 GB file and the processing of these steps was more and going for hours as i am reading each line.

So.. i thought of removing the whole individual columns itself and print the column output in the above printf format.

As this will not read each line and processing would be fast.

Let me know if you need more information.

Regards
Dhana
  #4 (permalink)  
Old 05-11-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
As I said, awk has a printf built-in to it. Read the man page.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0