![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Alignment of terms to the left | Raynon | Shell Programming and Scripting | 2 | 09-11-2007 09:35 PM |
| Column Alignment | nikncha | UNIX for Dummies Questions & Answers | 3 | 12-07-2006 10:20 PM |
| output display alignment !! | rosh0623 | Shell Programming and Scripting | 7 | 07-21-2005 07:51 PM |
| Using printf to center | CSGUY | Shell Programming and Scripting | 2 | 04-19-2005 10:15 PM |
| alignment in shell script | krishna | UNIX for Advanced & Expert Users | 1 | 09-10-2001 09:09 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
PrintF and AWK => Center Alignment?
Alright, I'm relativly new to the Unix enviroment and C in general. I'm writing a script for AWK to search through a file and return what it finds with a center alignment, but so far, I can't get it to work. If anyone could help me out, I'd really appreciate it.
|
|
||||
|
Ruby: Code:
"xxx".center(9)
==>" xxx "
Awk: Code:
BEGIN {
print ">" center( "xxx", 9 ) "<"
}
function center( str, n ,left,right )
{ right = int((n - length(str)) / 2)
left = n - length(str) - right
return sprintf( "%" left "s%s%" right "s", "", str, "" )
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|