[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference 7.286::korn_shell_programming

Title:Welcome to Korn_Shell_Programming
Moderator:PLUGH::needle
Created:Tue Jun 25 1991
Last Modified:Fri May 30 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:118
Total number of notes:426

115.0. "printf in ksh" by NNTPD::"[email protected]" (Janice Chang) Wed Apr 30 1997 14:41

Hi.  Is there a printf function in ksh?  Basically I would like
to be able to format output with more flexibility than simply 
using tabs with echo.  Something like the C function printf 
would be excellent.  Thanks for any information.
[Posted by WWW Notes gateway]
T.RTitleUserPersonal
Name
DateLines
115.1SPECXN::DERAMODan D'EramoThu May 01 1997 12:2416
        The command
        
            $ man ksh | col -bh | grep -i printf
        
        doesn't show anything.  I know awk has a built-in printf and
        surely perl must have one as well.  At worst you can try to
        figure out how to properly quote something like
        
            $ awk 'BEGIN { printf "%-6d %4s %3d\n", 3, "ab", 12 }' < /dev/null
            3        ab  12
        
        so that the variables holding the values 3, "ab", and 12 get
        expanded properly.
        
        Dan
        
115.2NNTPD::&quot;[email protected]&quot;Janice ChangFri May 02 1997 11:575
Thanks.  I am now using awk, and it is quite powerful for what I need.


[Posted by WWW Notes gateway]
115.3WRLDYD::BOURQUESat May 03 1997 00:2112
New versions of korn shell has the printf capabiliity, unfortunately, the 
version released with digital unix does not have it


    <<< Note 115.2 by NNTPD::"[email protected]" "Janice Chang" >>>


Thanks.  I am now using awk, and it is quite powerful for what I need.


[Posted by WWW Notes gateway]

115.4/usr/bin/printfSAPEC3::WALLMEROTHMon May 05 1997 05:102
    at least since V3.2C 'type printf' gives you 'usr/bin/printf' and
    'man printf' shows a chapter 1 manpage.
115.5SPECXN::DERAMODan D&#039;EramoThu May 08 1997 16:367
        Neat!  In fact at least since "V3.0 347" there has been
        a /usr/bin/printf ...
        
        	pinkft> uname -a 
        	OSF1 pinkft.cxo.dec.com V3.0 347 alpha
        
        Dan