![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| rare problem -reinstalling formatting nothing is working | simaich8 | Linux | 0 | 11-04-2007 02:07 AM |
| Formatting Substitution Command Not Working in vi | ERPKEN | UNIX for Advanced & Expert Users | 11 | 05-06-2007 09:36 PM |
| plugging out value from a textfile | snowfrost | Shell Programming and Scripting | 7 | 01-22-2007 04:30 AM |
| looping a array inside inside ssh is not working, pls help | reldb | Shell Programming and Scripting | 5 | 07-07-2006 10:32 AM |
| how to find Script file location inside script | asami | Shell Programming and Scripting | 10 | 03-15-2006 12:57 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
formatting textfile inside ksh script using awk not working
I cannot seem to get this text file to format. Its as if the awk statement is being treated as a simple cat command.
I manned awk and it was very confusing. I viewed previous posts on this board and I got the same results as with the the awk command statement shown here. Please help. <<<contents of msgfile.txt>>> $ cat msgfile.txt Firstname1,Lastname1,Initial Firstname2,Lastname2,Initial2 Firstname3,Lastname3,Initial3 Firstname4,Lastname4,Initial4 Firstname5,Lastname5,Initial5 <<<program code - this needs to be within ksh>>> #!usr/bin/ksh awk -F":" '{ print $1 "\t" $2 "\t" $3 }' msgfile.txt <<<script output>>> $ ksh tmail2.ksh Firstname1,Lastname1,Initial Firstname2,Lastname2,Initial2 Firstname3,Lastname3,Initial3 Firstname4,Lastname4,Initial4 Firstname5,Lastname5,Initial5 |
|
|||||
|
Since i like using printf for formatting in awk , you can try this also,
Code:
awk -F"," '{printf"%-20s %-20s %-20s\n",$1,$2,$3}' msgfile.txt
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|