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
Comparing column of variable length anf fixed width file manneni prakash Shell Programming and Scripting 5 06-25-2008 01:46 AM
Replacing column with column of another file manneni prakash UNIX for Advanced & Expert Users 1 06-24-2008 11:27 PM
Replacing column with column of another file manneni prakash UNIX for Dummies Questions & Answers 1 06-24-2008 11:20 PM
How to check Null values in a file column by column if columns are Not NULLs Mandab Shell Programming and Scripting 7 03-15-2008 09:57 AM
Replace 10th column with a new column--- Terriblly hurry ahmedwaseem2000 Shell Programming and Scripting 2 09-06-2005 01:10 AM

Reply
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 07-01-2008
manneni prakash manneni prakash is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 30
Changing one column of delimited file column to fixed width column

Hi, Iam new to unix. I have one input file .

Input file :

ID1~Name1~Place1
ID2~Name2~Place2
ID3~Name3~Place3

I need output such that only first column should change to fixed width column of 15 characters of length.

Output File:

ID1<<12 spaces>>Name1~Place1
ID2<<12 spaces>>Name2~Place2
ID3<<12 spaces>>Name3~Place3

Thanks in advance.

Last edited by manneni prakash; 07-01-2008 at 02:33 AM..
  #2 (permalink)  
Old 07-01-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
Code:
awk -F"~" '{printf("%-15s%s~%s\n", $1,$2,$3)}' inputfile
ID1            Name1~Place1
ID2            Name2~Place2
ID3            Name3~Place3
  #3 (permalink)  
Old 07-01-2008
manneni prakash manneni prakash is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 30
Thanks

It works .............. Thanks Zaxxon
  #4 (permalink)  
Old 06-22-2009
kingpeejay kingpeejay is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 66
Smile edit columns in unix shell script

please disregard this post of mine.thanks!

Last edited by kingpeejay; 06-22-2009 at 04:33 AM.. Reason: wrong post
  #5 (permalink)  
Old 06-22-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,390
this will also do
Code:
printf "%-15s%s~%s\n" $(tr '~' ' '<inputfile)
  #6 (permalink)  
Old 06-22-2009
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,078
Code:
nawk -F"~" '{printf("%-15s%s~%s\n",$1,$2,$3)}' yourfile
Sponsored Links
Reply

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 12:51 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