Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

printf(3) [php man page]

PRINTF(3)								 1								 PRINTF(3)

printf - Output a formatted string

int printf (string $format, [mixed $args], [mixed $...]) DESCRIPTION
Produces output according to $format. PARAMETERS
o $format - See sprintf(3) for a description of $format. o $args - o $... - RETURN VALUES
Returns the length of the outputted string. SEE ALSO
print(3), sprintf(3), vprintf(3), sscanf(3), fscanf(3), flush(3). PHP Documentation Group PRINTF(3)

Check Out this Related Man Page

FPRINTF(3)								 1								FPRINTF(3)

fprintf - Write a formatted string to a stream

int fprintf (resource $handle, string $format, [mixed $args], [mixed $...]) DESCRIPTION
Write a string produced according to $format to the stream resource specified by $handle. PARAMETERS
o $handle -A file system pointer resource that is typically created using fopen(3). o $format - See sprintf(3) for a description of $format. o $args - o $... - RETURN VALUES
Returns the length of the string written. EXAMPLES
Example #1 fprintf(3): zero-padded integers <?php if (!($fp = fopen('date.txt', 'w'))) { return; } fprintf($fp, "%04d-%02d-%02d", $year, $month, $day); // will write the formatted ISO date to date.txt ?> Example #2 fprintf(3): formatting currency <?php if (!($fp = fopen('currency.txt', 'w'))) { return; } $money1 = 68.75; $money2 = 54.35; $money = $money1 + $money2; // echo $money will output "123.1"; $len = fprintf($fp, '%01.2f', $money); // will write "123.10" to currency.txt echo "wrote $len bytes to currency.txt"; // use the return value of fprintf to determine how many bytes we wrote ?> SEE ALSO
printf(3), sprintf(3), sscanf(3), fscanf(3), vsprintf(3), number_format(3). PHP Documentation Group FPRINTF(3)

15 More Discussions You Might Find Interesting

1. Programming

Multithreading in Pro*C

:confused: Hi! I have created a Multhreaded Application in Pro*C (using pthreads) with about 5 Threads running simultaneously. The Application is basically to Update a Centralized Table in Oracle, which updates different rows in the Table (Each Thread updates different rows!). The... (16 Replies)
Discussion started by: shaik786
16 Replies

2. Shell Programming and Scripting

How do I stop printf output from going into seperate txt files

I am using printf "%-75s%+10s %5s %1s \n" $s $z $x $y > status It works really well, however, when I email status it is sending 10 emails when I would like it to be in one. Is there a way to make all the output to go into one instance of a txt file. Yet still keep it 1 on each... (12 Replies)
Discussion started by: chrchcol
12 Replies

3. UNIX for Dummies Questions & Answers

Printf unix command

Where would I get a good explanation for all the possibities when using the "printf" unix commmand. (14 Replies)
Discussion started by: 1184jap
14 Replies

4. Shell Programming and Scripting

printf / regex

Morning folks, I need help with the following issue: Let's say we I have the following output: First Name: Test Last Name: Test2 Number: T1234 Number2: T1234 Needed Output: T1234 Now I want to grep/nawk/printf/sed out the Number: (13 Replies)
Discussion started by: domi55
13 Replies

5. Shell Programming and Scripting

repeat character with printf

It's all in the subject. I try to figure out how to repeat a character a number of time with printf. For example to draw a line in a script output. Thks (13 Replies)
Discussion started by: ripat
13 Replies

6. UNIX for Dummies Questions & Answers

The meaning of %s in printf

I have this command like that has %s in it, I know %s calls a column, but I am not sure I understand which column (I mean for my case I can check the input file, but I want to know how is this %s used, how comes tha same symbo; gives different columns in one command line: {printf "grep %s... (22 Replies)
Discussion started by: cosmologist
22 Replies

7. Programming

Masking Password with *'s

So I've been working on this for some time now and can't seem to find the solution that works for me. I'm working in C/Unix. Basically, I want to take a user input and output something different. For example, I want to take a password and output *'s. In another instance, I want to take inputed... (35 Replies)
Discussion started by: bigdrock44
35 Replies

8. Shell Programming and Scripting

Variable inside AWK printf

Hi, Is it possible to print a variable inside awk printf ?? the above is not working (13 Replies)
Discussion started by: selvankj
13 Replies

9. Shell Programming and Scripting

Problems with awk printf, formatted output

Hi, i have a script, which is incomplete, am on my way developing it. Input 1,12,2012,IF_TB001 2,12,2012,3K3 3,Z56,00000,25,229,K900,00, ,3G3, ,USD, ,0000000000,000, , , , 550000000 3,Z56,00000,53,411,W225,00,000, , ,USD,OM170,0000000000,000, , , , -550000000 4,Z56,COUNT, 4,SUM LOC,... (19 Replies)
Discussion started by: selvankj
19 Replies

10. Shell Programming and Scripting

File Splitter output filename

Issue: I am able to split source file in multiple files of 10 rows each but unable to get the required outputfile name. please advise. Details: input = A.txt having 44 rows required output = A_001.txt , A_002.txt and so on. Can below awk be modified to give required result current... (19 Replies)
Discussion started by: santosh2k2
19 Replies

11. Programming

What is the difference between printf and putchar() or scanf and getchar() ?

Im a newbie to programming language, i found tat there r these function called printf and putchar() as well as scanf and getchar(), im curious abt why do dey hav these 2 different function although dey r doing the same instruction? :confused: (13 Replies)
Discussion started by: kris26
13 Replies

12. Shell Programming and Scripting

Need help in printf in shell script

My requirement is need to add spaces to the string with the dynamic value to printf... this is a part of shell script ..which i have , the length is not static ... length=15 value="1234567890" printf "%-"$length"s\n" "$value"; The result it is printing is ... i am not sure y it is... (19 Replies)
Discussion started by: greenworld123
19 Replies

13. Shell Programming and Scripting

Printf statement for currency conversion

hi all, I had my script as a=qw b=rter c=fdfd curency=1000 printf"${curency} $a $b $c" > filename can i have printf statement that can change the currency from 1000 to 1,000 like it should convert the number to currency format ..?(i.e for any number) (14 Replies)
Discussion started by: hemanthsaikumar
14 Replies

14. Shell Programming and Scripting

Printf padded string

Is possible to print padded string in printf? Example echo 1 | awk '{printf("%03d\n", $1)}' 001I want S1 S11 S2 S21to be padded as: S01 S11 S02 S21Thanks! (26 Replies)
Discussion started by: yifangt
26 Replies

15. Shell Programming and Scripting

Change date time stamp of existing file

I have a file hello.txt which was created today (today's date timestamp) I wish to change its date timestamp (access, modified, created) to 1 week old i.e one week from now. uname -a SunOS mymac 5.11 11.2 sun4v sparc sun4v Can you please suggest a easy way to do that ? (12 Replies)
Discussion started by: mohtashims
12 Replies

Featured Tech Videos