![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Retrieve 5th Field to Last Field !! | jobbyjoseph | UNIX for Dummies Questions & Answers | 3 | 05-16-2007 12:20 AM |
| Moving Part of a field to another field using AWK | rjsha1 | Shell Programming and Scripting | 5 | 08-04-2006 02:39 AM |
| add increment field when first field changes | azekry | Shell Programming and Scripting | 2 | 11-14-2005 01:21 PM |
| Cut the last field | 435 Gavea | Shell Programming and Scripting | 6 | 12-09-2003 03:37 AM |
| awk sub-field? | kristy | UNIX for Dummies Questions & Answers | 2 | 10-05-2001 01:07 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
awk right justify field
I didn't notise in the post "awk sed or paste" a right justifying charachter. IS there one? My fields looks like this:
cis101 01 Microcomputer Applications 11:00 cis101 02 Microcomputer Applications 9:00 cis101 DL Microcomputer Applications 7:00 cis106 01 Introduction to Programming 10:00 cis106 02 Introduction to Programming 12:00 cis111 01 Internet and Web Authoring 9:00 cis111 02 Internet and Web Authoring 6:00 cis115 01 Object Oriented Prog 11:00 cis120 01 Using SQL Server 10:00 cis136 01 Introduction to Unix 6:00 cis162 01 Java I 9:00 cis168 01 Web Graphics 1:00 cis172 01 Visual Basic I 10:00 cis236 01 Database Management 12:00 cis262 01 Java II 9:00 cis272 01 Visual Basic II 1:00 and I can't seem to get the time column to line up Any suggestions? R |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Use a numeric value to print the number of spaces desired before the character(s) being printed. Use a - to reverse the justification. Using a . to represent a space you can see the effect..
printf "%4s", "foobar" prints . . . . foobar and printf "%-4s", "foobar" prints foobar. . . . Also note, in awk, an integer constant followed by a $ is a positional specifier. Normally, format specifications are applied to arguments in the order given in the format string. With a positional specifier, the format specification is applied to a specific argument, instead of what would be the next argument in the list. Positional specifiers begin counting with one. Thus: printf "%s %s\n", "don't", "panic" printf "%2$s %1$s\n", "panic", "don't" More On Awk printf |
||||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|