Sponsored Content
Top Forums Programming capture the output of printf into another variable Post 302443868 by arizah on Tuesday 10th of August 2010 09:22:33 AM
Old 08-10-2010
thanks Jim very handy this sprintf. Thanks!!!
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[csh] How to capture output from a command and pass it on to a variable?

Hi there! I'm trying to write a script that will capture output from a command and assign it to a variable. Let's say, for example, I'd like to catch from inside the script whatever the following command outputs: ls *.aaa and put it into a variable "listoffiles". What I tried was: set... (3 Replies)
Discussion started by: machinogodzilla
3 Replies

2. UNIX for Advanced & Expert Users

Help please...output problems with printf.

#include <stdio.h> #include <math.h> // this function calculates the volume of a Cylinder int main(void) { int r; // radius int h; // height double M_PI; // pi int pOne = pow (r, 2); // get user input of radius and height printf ("Enter your... (3 Replies)
Discussion started by: pwanda
3 Replies

3. Shell Programming and Scripting

printf Hexadecimal output

printf "%X\n" "A" 41 printf "%X\n" "2" 2 Expected 32 (not 2). Is there a "printf" which will output the hexadecimal value of a numeric character? (9 Replies)
Discussion started by: methyl
9 Replies

4. UNIX for Dummies Questions & Answers

Capture Multiple Lines Into Variable As Of Standard Output

Hello All, I have the below script and output. cat test.sh #!/bin/bash -x logit() { echo " - ${*}" > ${LOG_FILE} } LOG_FILE=/home/infrmtca/bin/findtest.log VAR=`find . -type f -name "*sql"` logit $VAR Output: cat /home/infrmtca/bin/findtest.log -... (9 Replies)
Discussion started by: Ariean
9 Replies

5. Shell Programming and Scripting

Excel table like output with printf

Hi All; I try to create a excel like table with headers and some fields containing values, other long and complex mathematic formulas. I have some header like : Name Formula Value True/False Under name column, they are some formula names, formula column some long mathematic formulas... (9 Replies)
Discussion started by: reseki
9 Replies

6. Shell Programming and Scripting

How to capture system() function output in variable

How to capture system() function output in awk variable and the print that awk variable..... (8 Replies)
Discussion started by: bharat1211
8 Replies

7. UNIX for Beginners Questions & Answers

How to use printf to output a shell variable path?

So I created two shell variables: COLUMN1_HEADING, COLUMN2_HEADING. They have values: COLUMN1_HEADING="John" COLUMN2_HEADING="123456789" How would I use printf to get it to print an output like this: $COLUMN1_HEADING\t$COLUMN2_HEADING\nJohn\t123456789\n Thanks! (3 Replies)
Discussion started by: steezuschrist96
3 Replies

8. Homework & Coursework Questions

How to Dynamically Pass Parameter to plsql Function & Capture its Output Value in a Shell Variable?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 2. Relevant commands, code, scripts, algorithms: #! /bin/ksh v="ORG_ID" ... (2 Replies)
Discussion started by: sujitdas2104
2 Replies
FSCANF(3)								 1								 FSCANF(3)

fscanf - Parses input from a file according to a format

SYNOPSIS
mixed fscanf (resource $handle, string $format, [mixed &$...]) DESCRIPTION
The function fscanf(3) is similar to sscanf(3), but it takes its input from a file associated with $handle and interprets the input according to the specified $format, which is described in the documentation for sprintf(3). Any whitespace in the format string matches any whitespace in the input stream. This means that even a tab in the format string can match a single space character in the input stream. Each call to fscanf(3) reads one line from the file. PARAMETERS
o $handle -A file system pointer resource that is typically created using fopen(3). o $format - The specified format as described in the sprintf(3) documentation. o $... - The optional assigned values. RETURN VALUES
If only two parameters were passed to this function, the values parsed will be returned as an array. Otherwise, if optional parameters are passed, the function will return the number of assigned values. The optional parameters must be passed by reference. EXAMPLES
Example #1 fscanf(3) Example <?php $handle = fopen("users.txt", "r"); while ($userinfo = fscanf($handle, "%s %s %s ")) { list ($name, $profession, $countrycode) = $userinfo; //... do something with the values } fclose($handle); ?> Example #2 Contents of users.txt javier argonaut pe hiroshi sculptor jp robert slacker us luigi florist it SEE ALSO
fread(3), fgets(3), fgetss(3), sscanf(3), printf(3), sprintf(3). PHP Documentation Group FSCANF(3)
All times are GMT -4. The time now is 05:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy